diff --git a/sdk/authorization/azure-mgmt-authorization/_meta.json b/sdk/authorization/azure-mgmt-authorization/_meta.json index 93b83d2d4425..8682b2687ee4 100644 --- a/sdk/authorization/azure-mgmt-authorization/_meta.json +++ b/sdk/authorization/azure-mgmt-authorization/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "ac1c84fa8c897975b88a38a66dd64d54312a1422", + "commit": "e3669554a8f85efa9564eec4191d79dfcc3c789a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/authorization/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/authorization/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/authorization/resource-manager/readme.md" } \ No newline at end of file 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 b276347dde37..c04efc8f6d1c 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 @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration @@ -23,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs): 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 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. + """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. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). @@ -45,8 +45,6 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. - :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 @@ -55,11 +53,19 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2015-07-01' + DEFAULT_API_VERSION = '2020-10-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'classic_administrators': '2015-07-01', + 'deny_assignments': '2018-07-01-preview', + 'global_administrator': '2015-07-01', + 'permissions': '2015-07-01', + 'provider_operations_metadata': '2015-07-01', + 'role_assignment_metrics': '2019-08-01-preview', + 'role_assignments': '2015-07-01', + 'role_definitions': '2015-07-01', }}, _PROFILE_TAG + " latest" ) @@ -67,15 +73,12 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, credential, # type: "TokenCredential" - subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, @@ -98,9 +101,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 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` """ if api_version == '2015-06-01': from .v2015_06_01 import models @@ -126,6 +132,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): 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 @@ -135,6 +144,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): 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 raise ValueError("API version {} is not available".format(api_version)) @property @@ -143,44 +158,130 @@ def access_review_default_settings(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -191,12 +292,18 @@ def access_review_instance_my_decisions(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -207,12 +314,18 @@ def access_review_instances(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -223,12 +336,18 @@ def access_review_instances_assigned_for_my_approval(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -239,12 +358,18 @@ def access_review_schedule_definitions(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -255,12 +380,18 @@ def access_review_schedule_definitions_assigned_for_my_approval(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -298,10 +429,13 @@ def deny_assignments(self): 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-preview': + 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)) @@ -327,6 +461,8 @@ def operations(self): * 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': @@ -335,6 +471,10 @@ def operations(self): 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -427,10 +567,13 @@ def role_assignment_metrics(self): 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-preview': + 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)) @@ -440,10 +583,13 @@ def role_assignment_schedule_instances(self): def role_assignment_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` """ api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01-preview': + 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 else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) @@ -453,10 +599,13 @@ def role_assignment_schedule_requests(self): 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-preview': + 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)) @@ -507,10 +656,13 @@ def role_definitions(self): 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-preview': + 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)) @@ -520,10 +672,13 @@ def role_eligibility_schedule_instances(self): def role_eligibility_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` """ api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01-preview': + 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 else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) @@ -533,10 +688,13 @@ def role_eligibility_schedule_requests(self): 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-preview': + 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)) @@ -546,10 +704,13 @@ def role_eligibility_schedules(self): 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-preview': + 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)) @@ -559,15 +720,148 @@ def role_management_policies(self): 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-preview': + 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def scope_role_assignment_approval(self): """Instance depends on the API version: @@ -607,6 +901,22 @@ def scope_role_assignment_approval_steps(self): raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + def close(self): self._client.close() def __enter__(self): 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 23336d3cc79e..64f8e7858df0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -30,25 +30,19 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str """ def __init__( self, credential, # type: "TokenCredential" - subscription_id, # type: str **kwargs # type: Any ): # type: (...) -> 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._configure(**kwargs) @@ -68,4 +62,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py index 931b122b8db7..0a0001798864 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 @@ -11,16 +11,17 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -31,7 +32,7 @@ def __init__(self, *args, **kwargs): 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 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. + """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. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). @@ -43,8 +44,6 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. - :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 @@ -53,11 +52,19 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2015-07-01' + DEFAULT_API_VERSION = '2020-10-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'classic_administrators': '2015-07-01', + 'deny_assignments': '2018-07-01-preview', + 'global_administrator': '2015-07-01', + 'permissions': '2015-07-01', + 'provider_operations_metadata': '2015-07-01', + 'role_assignment_metrics': '2019-08-01-preview', + 'role_assignments': '2015-07-01', + 'role_definitions': '2015-07-01', }}, _PROFILE_TAG + " latest" ) @@ -65,15 +72,12 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, credential: "AsyncTokenCredential", - subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, @@ -96,9 +100,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 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` """ if api_version == '2015-06-01': from ..v2015_06_01 import models @@ -124,6 +131,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): 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 @@ -133,6 +143,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): 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 raise ValueError("API version {} is not available".format(api_version)) @property @@ -141,44 +157,130 @@ def access_review_default_settings(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -189,12 +291,18 @@ def access_review_instance_my_decisions(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -205,12 +313,18 @@ def access_review_instances(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -221,12 +335,18 @@ def access_review_instances_assigned_for_my_approval(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -237,12 +357,18 @@ def access_review_schedule_definitions(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -253,12 +379,18 @@ def access_review_schedule_definitions_assigned_for_my_approval(self): * 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -296,10 +428,13 @@ def deny_assignments(self): 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-preview': + 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)) @@ -325,6 +460,8 @@ def operations(self): * 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': @@ -333,6 +470,10 @@ def operations(self): 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -425,10 +566,13 @@ def role_assignment_metrics(self): 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-preview': + 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)) @@ -438,10 +582,13 @@ def role_assignment_schedule_instances(self): def role_assignment_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` """ api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01-preview': + 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 else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) @@ -451,10 +598,13 @@ def role_assignment_schedule_requests(self): 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-preview': + 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)) @@ -505,10 +655,13 @@ def role_definitions(self): 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-preview': + 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)) @@ -518,10 +671,13 @@ def role_eligibility_schedule_instances(self): def role_eligibility_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` """ api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01-preview': + 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 else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) @@ -531,10 +687,13 @@ def role_eligibility_schedule_requests(self): 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-preview': + 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)) @@ -544,10 +703,13 @@ def role_eligibility_schedules(self): 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-preview': + 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)) @@ -557,15 +719,148 @@ def role_management_policies(self): 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-preview': + 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)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def scope_role_assignment_approval(self): """Instance depends on the API version: @@ -605,6 +900,22 @@ def scope_role_assignment_approval_steps(self): raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + async def close(self): await self._client.close() async def __aenter__(self): 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 cf4c9ef9bf99..055b4024ff39 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 @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -28,24 +28,18 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str """ def __init__( self, credential: "AsyncTokenCredential", - subscription_id: str, **kwargs # type: 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._configure(**kwargs) @@ -64,4 +58,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py index 3fc87a882b88..b51c857f3afa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py @@ -5,3 +5,6 @@ # license information. # -------------------------------------------------------------------------- from .v2015_07_01.models import * +from .v2018_07_01_preview.models import * +from .v2019_08_01_preview.models import * +from .v2020_10_01.models import * 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 0dca81078c2d..188c5371ea3f 100644 --- 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 @@ -6,73 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype classic_administrators: + azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 9f3e1d521653..e000eba5742b 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + 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.api_version = "2015-06-01" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json index 93f9a8785b8c..84208c274954 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index cb8cddb257ed..5301fd5c9794 100644 --- 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 @@ -6,69 +6,86 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype classic_administrators: + azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index 1310486fc391..7de898450f46 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + 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.api_version = "2015-06-01" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/__init__.py index 649828c5f3b8..156860661b3a 100644 --- 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 @@ -8,6 +8,11 @@ from ._classic_administrators_operations import ClassicAdministratorsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 index 824b5fc117b3..70ee4289890c 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,96 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ClassicAdministratorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ClassicAdministratorListResult"]: + ) -> AsyncIterable[_models.ClassicAdministratorListResult]: """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 ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClassicAdministratorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +104,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore 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/v2015_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py index 32a64afe5356..c0cbbab833a9 100644 --- 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 @@ -6,19 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ClassicAdministrator # type: ignore - from ._models import ClassicAdministratorListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ClassicAdministrator', 'ClassicAdministratorListResult', @@ -26,3 +22,5 @@ 'ErrorDetail', 'ErrorResponse', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py deleted file mode 100644 index fcb7089a6617..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py +++ /dev/null @@ -1,163 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ClassicAdministrator(msrest.serialization.Model): - """Classic Administrators. - - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type 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, - **kwargs - ): - super(ClassicAdministrator, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.email_address = kwargs.get('email_address', None) - self.role = kwargs.get('role', None) - - -class ClassicAdministratorListResult(msrest.serialization.Model): - """ClassicAdministrator list result information. - - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ClassicAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministratorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) 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 index 9c121234dcd4..007fad601f2e 100644 --- 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 @@ -6,25 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ClassicAdministrator(msrest.serialization.Model): """Classic Administrators. - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str + :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 = { @@ -45,6 +49,18 @@ def __init__( role: Optional[str] = None, **kwargs ): + """ + :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(ClassicAdministrator, self).__init__(**kwargs) self.id = id self.name = name @@ -56,10 +72,10 @@ def __init__( class ClassicAdministratorListResult(msrest.serialization.Model): """ClassicAdministrator list result information. - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -70,10 +86,16 @@ class ClassicAdministratorListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ClassicAdministrator"]] = None, + value: Optional[List["_models.ClassicAdministrator"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(ClassicAdministratorListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -104,6 +126,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +171,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +184,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ _attribute_map = { @@ -169,8 +195,12 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error 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/v2015_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/__init__.py index 649828c5f3b8..156860661b3a 100644 --- 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 @@ -8,6 +8,11 @@ from ._classic_administrators_operations import ClassicAdministratorsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 index d1a65c48396f..eec19f7ba0ab 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,132 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ClassicAdministratorsOperations(object): - """ClassicAdministratorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClassicAdministratorListResult"] + **kwargs: Any + ) -> Iterable[_models.ClassicAdministratorListResult]: """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 ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClassicAdministratorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +140,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index b40276826ca5..c68c020c38fc 100644 --- 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 @@ -6,98 +6,115 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from .operations import ProviderOperationsMetadataOperations -from .operations import GlobalAdministratorOperations -from .operations import RoleAssignmentsOperations -from .operations import ClassicAdministratorsOperations from . import models +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(object): - """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. +class AuthorizationManagementClient: + """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 + :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 + :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 + :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 + :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 + :vartype classic_administrators: + azure.mgmt.authorization.v2015_07_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 1f5e4f5da82c..a85c3a180b3c 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + 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.api_version = "2015-07-01" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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_07_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json index 49f02d470747..9fb2ce46132b 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index 1061b48b1e9b..fdd49e1b6e64 100644 --- 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 @@ -6,94 +6,115 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from .operations import ProviderOperationsMetadataOperations -from .operations import GlobalAdministratorOperations -from .operations import RoleAssignmentsOperations -from .operations import ClassicAdministratorsOperations from .. import models +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(object): - """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. +class AuthorizationManagementClient: + """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 + :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 + :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 + :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 + :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 + :vartype classic_administrators: + azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index a75a520500e4..0a9d7abc1609 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + 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.api_version = "2015-07-01" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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_07_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 751b809fce00..8d320c9c1646 100644 --- 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 @@ -13,6 +13,9 @@ from ._role_assignments_operations import RoleAssignmentsOperations from ._classic_administrators_operations import ClassicAdministratorsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'PermissionsOperations', 'RoleDefinitionsOperations', @@ -21,3 +24,5 @@ 'RoleAssignmentsOperations', 'ClassicAdministratorsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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/v2015_07_01/aio/operations/_classic_administrators_operations.py index 32391e0679de..a494dd8c997e 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/v2015_07_01/aio/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,96 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ClassicAdministratorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :attr:`classic_administrators` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ClassicAdministratorListResult"]: + ) -> AsyncIterable[_models.ClassicAdministratorListResult]: """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 ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClassicAdministratorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +104,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore 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/v2015_07_01/aio/operations/_global_administrator_operations.py index 058e29364251..817933ed00a1 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/v2015_07_01/aio/operations/_global_administrator_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,44 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._global_administrator_operations import build_elevate_access_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GlobalAdministratorOperations: - """GlobalAdministratorOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :attr:`global_administrator` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + - async def elevate_access( + @distributed_trace_async + async def elevate_access( # pylint: disable=inconsistent-return-statements self, **kwargs: Any ) -> None: @@ -51,35 +54,41 @@ async def elevate_access( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.elevate_access.metadata['url'] # type: ignore + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - elevate_access.metadata = {'url': '/providers/Microsoft.Authorization/elevateAccess'} # type: ignore + elevate_access.metadata = {'url': "/providers/Microsoft.Authorization/elevateAccess"} # type: ignore + 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py index b050a906cffc..eedf14becfa6 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/v2015_07_01/aio/operations/_permissions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,100 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """PermissionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :attr:`permissions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PermissionGetResult"]: + ) -> AsyncIterable[_models.PermissionGetResult]: """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. :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,21 +108,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -120,7 +137,7 @@ def list_for_resource( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PermissionGetResult"]: + ) -> AsyncIterable[_models.PermissionGetResult]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -135,47 +152,59 @@ def list_for_resource( :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +213,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore 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/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py index c8e7457bb267..da9ae82547a5 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/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,95 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ProviderOperationsMetadataOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :attr:`provider_operations_metadata` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, resource_provider_namespace: str, expand: Optional[str] = "resourceTypes", **kwargs: Any - ) -> "_models.ProviderOperationsMetadata": + ) -> _models.ProviderOperationsMetadata: """Gets provider operations metadata for the specified resource provider. :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadata"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadata] + + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -98,53 +103,66 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", **kwargs: Any - ) -> AsyncIterable["_models.ProviderOperationsMetadataListResult"]: + ) -> AsyncIterable[_models.ProviderOperationsMetadataListResult]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :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 ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadataListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,17 +171,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore 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 index eb201def6556..6eeba62e083d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -50,7 +54,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,53 +69,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,76 +137,91 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,27 +230,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -230,37 +268,39 @@ async def delete( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,15 +311,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -289,8 +332,8 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters @@ -299,42 +342,43 @@ async def create( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,14 +387,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -362,37 +409,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,13 +450,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -420,36 +472,38 @@ async def delete_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -460,14 +514,17 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -482,41 +539,42 @@ async def create_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -525,13 +583,16 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -544,36 +605,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -582,59 +645,70 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -643,75 +717,89 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -720,17 +808,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index 1de28f66337e..064be2015d5e 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def delete( self, scope: str, role_definition_id: str, **kwargs: Any - ) -> Optional["_models.RoleDefinition"]: + ) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -58,37 +62,39 @@ async def delete( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleDefinition"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleDefinition]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -99,14 +105,17 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_definition_id: str, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -118,37 +127,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -157,15 +168,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: "_models.RoleDefinition", + role_definition: _models.RoleDefinition, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -179,42 +193,43 @@ async def create_or_update( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + _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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -223,61 +238,72 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleDefinitionListResult"]: + ) -> AsyncIterable[_models.RoleDefinitionListResult]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + 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 RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,26 +312,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_definition_id: str, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_definition_id: The fully qualified role definition ID. Use the format, @@ -319,36 +351,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -357,4 +391,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleDefinitionId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleDefinitionId}"} # type: ignore + 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 index 0440ade890b1..73eaf75c95da 100644 --- 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 @@ -6,49 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ClassicAdministrator # type: ignore - from ._models import ClassicAdministratorListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Permission # type: ignore - from ._models import PermissionGetResult # type: ignore - from ._models import ProviderOperation # type: ignore - from ._models import ProviderOperationsMetadata # type: ignore - from ._models import ProviderOperationsMetadataListResult # type: ignore - from ._models import ResourceType # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleAssignmentProperties # type: ignore - from ._models import RoleAssignmentPropertiesWithScope # type: ignore - from ._models import RoleDefinition # type: ignore - from ._models import RoleDefinitionFilter # type: ignore - from ._models import RoleDefinitionListResult # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ClassicAdministrator', 'ClassicAdministratorListResult', @@ -71,3 +52,5 @@ 'RoleDefinitionFilter', 'RoleDefinitionListResult', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py deleted file mode 100644 index b8bd200b487e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py +++ /dev/null @@ -1,595 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ClassicAdministrator(msrest.serialization.Model): - """Classic Administrators. - - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type 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, - **kwargs - ): - super(ClassicAdministrator, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.email_address = kwargs.get('email_address', None) - self.role = kwargs.get('role', None) - - -class ClassicAdministratorListResult(msrest.serialization.Model): - """ClassicAdministrator list result information. - - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ClassicAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministratorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - """ - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - - -class PermissionGetResult(msrest.serialization.Model): - """Permissions information. - - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Permission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PermissionGetResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ProviderOperation(msrest.serialization.Model): - """Operation. - - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - """ - - _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, - **kwargs - ): - super(ProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class ProviderOperationsMetadata(msrest.serialization.Model): - """Provider Operations metadata. - - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :param operations: The provider operations. - :type 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, - **kwargs - ): - super(ProviderOperationsMetadata, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.display_name = kwargs.get('display_name', None) - self.resource_types = kwargs.get('resource_types', None) - self.operations = kwargs.get('operations', None) - - -class ProviderOperationsMetadataListResult(msrest.serialization.Model): - """Provider operations metadata list. - - :param value: The list of providers. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderOperationsMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceType(msrest.serialization.Model): - """Resource Type. - - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type 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, - **kwargs - ): - super(ResourceType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.operations = kwargs.get('operations', None) - - -class RoleAssignment(msrest.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 - :param properties: Role assignment properties. - :type 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, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs.get('properties', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param properties: Required. Role assignment properties. - :type properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties - """ - - _validation = { - 'properties': {'required': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RoleAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentProperties(msrest.serialization.Model): - """Role assignment properties. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type 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, - **kwargs - ): - super(RoleAssignmentProperties, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - - -class RoleAssignmentPropertiesWithScope(msrest.serialization.Model): - """Role assignment properties with scope. - - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type 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, - **kwargs - ): - super(RoleAssignmentPropertiesWithScope, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleDefinition(msrest.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 - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type 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, - **kwargs - ): - super(RoleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = kwargs.get('role_name', None) - self.description = kwargs.get('description', None) - self.role_type = kwargs.get('role_type', None) - self.permissions = kwargs.get('permissions', None) - self.assignable_scopes = kwargs.get('assignable_scopes', None) - - -class RoleDefinitionFilter(msrest.serialization.Model): - """Role Definitions filter. - - :param role_name: Returns role definition with the specific name. - :type role_name: str - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionFilter, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - - -class RoleDefinitionListResult(msrest.serialization.Model): - """Role definition list operation result. - - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) 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 index bf01a81e0ea1..886fdd2fbd13 100644 --- 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 @@ -6,25 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional +from typing import Any, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ClassicAdministrator(msrest.serialization.Model): """Classic Administrators. - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str + :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 = { @@ -45,6 +49,18 @@ def __init__( role: Optional[str] = None, **kwargs ): + """ + :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(ClassicAdministrator, self).__init__(**kwargs) self.id = id self.name = name @@ -56,10 +72,10 @@ def __init__( class ClassicAdministratorListResult(msrest.serialization.Model): """ClassicAdministrator list result information. - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -70,10 +86,16 @@ class ClassicAdministratorListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ClassicAdministrator"]] = None, + value: Optional[List["_models.ClassicAdministrator"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(ClassicAdministratorListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -104,6 +126,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +171,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +184,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail """ _attribute_map = { @@ -169,9 +195,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -179,10 +209,10 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] """ _attribute_map = { @@ -197,6 +227,12 @@ def __init__( not_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -205,10 +241,10 @@ def __init__( class PermissionGetResult(msrest.serialization.Model): """Permissions information. - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -219,10 +255,16 @@ class PermissionGetResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Permission"]] = None, + value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(PermissionGetResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -231,16 +273,16 @@ def __init__( class ProviderOperation(msrest.serialization.Model): """Operation. - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any + :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: any """ _attribute_map = { @@ -261,6 +303,18 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :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: any + """ super(ProviderOperation, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -272,18 +326,18 @@ def __init__( class ProviderOperationsMetadata(msrest.serialization.Model): """Provider Operations metadata. - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + :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 = { @@ -302,10 +356,24 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, display_name: Optional[str] = None, - resource_types: Optional[List["ResourceType"]] = None, - operations: Optional[List["ProviderOperation"]] = None, + resource_types: Optional[List["_models.ResourceType"]] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs ): + """ + :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(ProviderOperationsMetadata, self).__init__(**kwargs) self.id = id self.name = name @@ -318,10 +386,10 @@ def __init__( class ProviderOperationsMetadataListResult(msrest.serialization.Model): """Provider operations metadata list. - :param value: The list of providers. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -332,10 +400,16 @@ class ProviderOperationsMetadataListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ProviderOperationsMetadata"]] = None, + value: Optional[List["_models.ProviderOperationsMetadata"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(ProviderOperationsMetadataListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -344,12 +418,12 @@ def __init__( class ResourceType(msrest.serialization.Model): """Resource Type. - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + :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 = { @@ -363,9 +437,17 @@ def __init__( *, name: Optional[str] = None, display_name: Optional[str] = None, - operations: Optional[List["ProviderOperation"]] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs ): + """ + :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(ResourceType, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -383,8 +465,8 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param properties: Role assignment properties. - :type properties: + :ivar properties: Role assignment properties. + :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope """ @@ -404,9 +486,14 @@ class RoleAssignment(msrest.serialization.Model): def __init__( self, *, - properties: Optional["RoleAssignmentPropertiesWithScope"] = None, + properties: Optional["_models.RoleAssignmentPropertiesWithScope"] = None, **kwargs ): + """ + :keyword properties: Role assignment properties. + :paramtype properties: + ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -419,8 +506,8 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. Role assignment properties. - :type properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties + :ivar properties: Required. Role assignment properties. + :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties """ _validation = { @@ -434,9 +521,13 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): def __init__( self, *, - properties: "RoleAssignmentProperties", + properties: "_models.RoleAssignmentProperties", **kwargs ): + """ + :keyword properties: Required. Role assignment properties. + :paramtype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.properties = properties @@ -444,8 +535,8 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str """ _attribute_map = { @@ -458,6 +549,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id @@ -465,10 +560,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -479,10 +574,16 @@ class RoleAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignment"]] = None, + value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -493,11 +594,11 @@ class RoleAssignmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. 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. + :vartype principal_id: str """ _validation = { @@ -517,6 +618,13 @@ def __init__( principal_id: str, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. 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. + :paramtype principal_id: str + """ super(RoleAssignmentProperties, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -525,12 +633,12 @@ def __init__( class RoleAssignmentPropertiesWithScope(msrest.serialization.Model): """Role assignment properties with scope. - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: 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 """ _attribute_map = { @@ -547,6 +655,14 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentPropertiesWithScope, self).__init__(**kwargs) self.scope = scope self.role_definition_id = role_definition_id @@ -564,16 +680,16 @@ class RoleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The role definition type. :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[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 = { @@ -599,10 +715,22 @@ def __init__( role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, - permissions: Optional[List["Permission"]] = None, + permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs ): + """ + :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(RoleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -617,8 +745,8 @@ def __init__( class RoleDefinitionFilter(msrest.serialization.Model): """Role Definitions filter. - :param role_name: Returns role definition with the specific name. - :type role_name: str + :ivar role_name: Returns role definition with the specific name. + :vartype role_name: str """ _attribute_map = { @@ -631,6 +759,10 @@ def __init__( role_name: Optional[str] = None, **kwargs ): + """ + :keyword role_name: Returns role definition with the specific name. + :paramtype role_name: str + """ super(RoleDefinitionFilter, self).__init__(**kwargs) self.role_name = role_name @@ -638,10 +770,10 @@ def __init__( class RoleDefinitionListResult(msrest.serialization.Model): """Role definition list operation result. - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -652,10 +784,16 @@ class RoleDefinitionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleDefinition"]] = None, + value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleDefinitionListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 751b809fce00..8d320c9c1646 100644 --- 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 @@ -13,6 +13,9 @@ from ._role_assignments_operations import RoleAssignmentsOperations from ._classic_administrators_operations import ClassicAdministratorsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'PermissionsOperations', 'RoleDefinitionsOperations', @@ -21,3 +24,5 @@ 'RoleAssignmentsOperations', 'ClassicAdministratorsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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/v2015_07_01/operations/_classic_administrators_operations.py index ff02d9d6c5f2..07adc7f76078 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/v2015_07_01/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,132 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ClassicAdministratorsOperations(object): - """ClassicAdministratorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s + :attr:`classic_administrators` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClassicAdministratorListResult"] + **kwargs: Any + ) -> Iterable[_models.ClassicAdministratorListResult]: """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 ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClassicAdministratorListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +140,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore 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/v2015_07_01/operations/_global_administrator_operations.py index bb011b71baed..1a15b0c5a018 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/v2015_07_01/operations/_global_administrator_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,77 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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_elevate_access_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/elevateAccess") -class GlobalAdministratorOperations(object): - """GlobalAdministratorOperations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class GlobalAdministratorOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s + :attr:`global_administrator` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def elevate_access( + + @distributed_trace + def elevate_access( # pylint: disable=inconsistent-return-statements self, - **kwargs # type: Any - ): - # type: (...) -> None + **kwargs: Any + ) -> None: """Elevates access for a Global Administrator. :keyword callable cls: A custom type or function that will be passed the direct response @@ -56,35 +84,41 @@ def elevate_access( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.elevate_access.metadata['url'] # type: ignore + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - elevate_access.metadata = {'url': '/providers/Microsoft.Authorization/elevateAccess'} # type: ignore + elevate_access.metadata = {'url': "/providers/Microsoft.Authorization/elevateAccess"} # type: ignore + 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index c5d6a3068837..93835edd788d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,181 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class PermissionsOperations(object): - """PermissionsOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PermissionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.PermissionGetResult]: """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. :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,31 +189,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable[_models.PermissionGetResult]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,47 +233,59 @@ def list_for_resource( :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -190,17 +294,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore 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 index 66d1bcd92e82..0a942b64b9e3 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,165 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) -class ProviderOperationsMetadataOperations(object): - """ProviderOperationsMetadataOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - resource_provider_namespace, # type: str - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProviderOperationsMetadata" + resource_provider_namespace: str, + expand: Optional[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. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadata"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadata] + + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -103,54 +173,66 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProviderOperationsMetadataListResult"] + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> Iterable[_models.ProviderOperationsMetadataListResult]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :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 ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadataListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -159,17 +241,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore 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 index 42f104b69284..f4f406fedb38 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,57 +6,437 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentsOperations(object): - """RoleAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + 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.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +451,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +519,91 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +612,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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. @@ -237,37 +650,39 @@ def delete( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +693,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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 @@ -297,8 +714,8 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters @@ -307,42 +724,43 @@ def create( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +769,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -371,37 +791,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +832,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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, @@ -430,36 +854,38 @@ def delete_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -470,15 +896,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **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, @@ -493,41 +921,42 @@ def create_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -536,14 +965,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + 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, @@ -556,36 +987,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -594,60 +1027,70 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -656,76 +1099,89 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -734,17 +1190,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index be3d299fb60a..4c4732d00150 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,236 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleDefinitionsOperations(object): - """RoleDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def delete( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleDefinition"] + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -63,37 +247,39 @@ def delete( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleDefinition"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleDefinition]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -104,15 +290,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> _models.RoleDefinition: """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -124,37 +312,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -163,16 +353,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def create_or_update( self, - scope, # type: str - role_definition_id, # type: str - role_definition, # type: "_models.RoleDefinition" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + role_definition: _models.RoleDefinition, + **kwargs: Any + ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -186,42 +378,43 @@ def create_or_update( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + _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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -230,62 +423,72 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleDefinitionListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleDefinitionListResult]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + 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 RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,27 +497,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + 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, @@ -328,36 +536,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -366,4 +576,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleDefinitionId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleDefinitionId}"} # type: ignore + 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 4441499e6885..0f652eb67c8f 100644 --- 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 @@ -6,88 +6,102 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations from . import models +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(object): - """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. +class AuthorizationManagementClient: + """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 + :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 + :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 + :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 + :vartype role_definitions: + azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 73fe3723d364..5be8a6160a6a 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + 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.api_version = "2018-01-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2018_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json index 9d42dccaf7c2..9ac482fac2ee 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index d22ed81ce409..e78e0f0ecc10 100644 --- 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 @@ -6,84 +6,102 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations from .. import models +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(object): - """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. +class AuthorizationManagementClient: + """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 + :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 + :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 + :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 + :vartype role_definitions: + azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index d32ebcc2d62f..6053946c363d 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + 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.api_version = "2018-01-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2018_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index be3e88f5724f..646069764687 100644 --- 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 @@ -11,9 +11,14 @@ from ._permissions_operations import PermissionsOperations from ._role_definitions_operations import RoleDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 0af7174cf8d9..147603261b3d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,100 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """PermissionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PermissionGetResult"]: + ) -> AsyncIterable[_models.PermissionGetResult]: """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. :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,21 +108,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -120,7 +137,7 @@ def list_for_resource( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PermissionGetResult"]: + ) -> AsyncIterable[_models.PermissionGetResult]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -135,47 +152,59 @@ def list_for_resource( :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +213,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore 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 index 6c6e26e27bb6..06789171eaea 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,95 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ProviderOperationsMetadataOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, resource_provider_namespace: str, expand: Optional[str] = "resourceTypes", **kwargs: Any - ) -> "_models.ProviderOperationsMetadata": + ) -> _models.ProviderOperationsMetadata: """Gets provider operations metadata for the specified resource provider. :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadata"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadata] + + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -98,53 +103,66 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", **kwargs: Any - ) -> AsyncIterable["_models.ProviderOperationsMetadataListResult"]: + ) -> AsyncIterable[_models.ProviderOperationsMetadataListResult]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :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 ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadataListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,17 +171,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore 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 index 776614cc3902..4056c8da3212 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -50,7 +54,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,53 +69,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,76 +137,91 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,27 +230,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -230,37 +268,39 @@ async def delete( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,15 +311,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -289,52 +332,54 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,14 +388,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -362,37 +410,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,13 +451,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -417,36 +470,38 @@ async def delete_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -457,60 +512,65 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -519,13 +579,16 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -535,36 +598,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -573,59 +638,70 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,75 +710,89 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -711,17 +801,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index e280640ef01d..985bd8b855af 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def delete( self, scope: str, role_definition_id: str, **kwargs: Any - ) -> Optional["_models.RoleDefinition"]: + ) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -58,37 +62,39 @@ async def delete( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleDefinition"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleDefinition]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -99,14 +105,17 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_definition_id: str, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -118,37 +127,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -157,15 +168,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: "_models.RoleDefinition", + role_definition: _models.RoleDefinition, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -179,42 +193,43 @@ async def create_or_update( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + _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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -223,61 +238,72 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleDefinitionListResult"]: + ) -> AsyncIterable[_models.RoleDefinitionListResult]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + 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 RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,26 +312,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_id: str, **kwargs: Any - ) -> "_models.RoleDefinition": + ) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, @@ -319,36 +351,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -357,4 +391,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + 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 index 28a31e633985..03aae2c2355c 100644 --- 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 @@ -6,41 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Permission # type: ignore - from ._models import PermissionGetResult # type: ignore - from ._models import ProviderOperation # type: ignore - from ._models import ProviderOperationsMetadata # type: ignore - from ._models import ProviderOperationsMetadataListResult # type: ignore - from ._models import ResourceType # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleDefinition # type: ignore - from ._models import RoleDefinitionFilter # type: ignore - from ._models import RoleDefinitionListResult # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ErrorAdditionalInfo', 'ErrorDetail', @@ -59,3 +44,5 @@ 'RoleDefinitionFilter', 'RoleDefinitionListResult', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py deleted file mode 100644 index b85e6f7ca84d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py +++ /dev/null @@ -1,521 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type 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, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -class PermissionGetResult(msrest.serialization.Model): - """Permissions information. - - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Permission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PermissionGetResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ProviderOperation(msrest.serialization.Model): - """Operation. - - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - :param is_data_action: The dataAction flag to specify the operation type. - :type 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, - **kwargs - ): - super(ProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - self.is_data_action = kwargs.get('is_data_action', None) - - -class ProviderOperationsMetadata(msrest.serialization.Model): - """Provider Operations metadata. - - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :param operations: The provider operations. - :type 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, - **kwargs - ): - super(ProviderOperationsMetadata, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.display_name = kwargs.get('display_name', None) - self.resource_types = kwargs.get('resource_types', None) - self.operations = kwargs.get('operations', None) - - -class ProviderOperationsMetadataListResult(msrest.serialization.Model): - """Provider operations metadata list. - - :param value: The list of providers. - :type value: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderOperationsMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceType(msrest.serialization.Model): - """Resource Type. - - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type 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, - **kwargs - ): - super(ResourceType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.operations = kwargs.get('operations', None) - - -class RoleAssignment(msrest.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 - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type 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, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param can_delegate: The delegation flag used for creating a role assignment. - :type 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, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleDefinition(msrest.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 - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type 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, - **kwargs - ): - super(RoleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = kwargs.get('role_name', None) - self.description = kwargs.get('description', None) - self.role_type = kwargs.get('role_type', None) - self.permissions = kwargs.get('permissions', None) - self.assignable_scopes = kwargs.get('assignable_scopes', None) - - -class RoleDefinitionFilter(msrest.serialization.Model): - """Role Definitions filter. - - :param role_name: Returns role definition with the specific name. - :type role_name: str - :param type: Returns role definition with the specific type. - :type type: str - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionFilter, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.type = kwargs.get('type', None) - - -class RoleDefinitionListResult(msrest.serialization.Model): - """Role definition list operation result. - - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) 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 index 86a699aa985f..af3dd7ccf8dd 100644 --- 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional +from typing import Any, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. @@ -37,6 +41,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +86,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +99,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail """ _attribute_map = { @@ -102,9 +110,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -112,14 +124,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :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 = { @@ -138,6 +150,16 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :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(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -148,10 +170,10 @@ def __init__( class PermissionGetResult(msrest.serialization.Model): """Permissions information. - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -162,10 +184,16 @@ class PermissionGetResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Permission"]] = None, + value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(PermissionGetResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -174,18 +202,18 @@ def __init__( class ProviderOperation(msrest.serialization.Model): """Operation. - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - :param is_data_action: The dataAction flag to specify the operation type. - :type is_data_action: bool + :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: any + :ivar is_data_action: The dataAction flag to specify the operation type. + :vartype is_data_action: bool """ _attribute_map = { @@ -208,6 +236,20 @@ def __init__( is_data_action: Optional[bool] = None, **kwargs ): + """ + :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: any + :keyword is_data_action: The dataAction flag to specify the operation type. + :paramtype is_data_action: bool + """ super(ProviderOperation, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -220,18 +262,20 @@ def __init__( class ProviderOperationsMetadata(msrest.serialization.Model): """Provider Operations metadata. - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + :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 = { @@ -250,10 +294,26 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, display_name: Optional[str] = None, - resource_types: Optional[List["ResourceType"]] = None, - operations: Optional[List["ProviderOperation"]] = None, + resource_types: Optional[List["_models.ResourceType"]] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs ): + """ + :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(ProviderOperationsMetadata, self).__init__(**kwargs) self.id = id self.name = name @@ -266,11 +326,11 @@ def __init__( class ProviderOperationsMetadataListResult(msrest.serialization.Model): """Provider operations metadata list. - :param value: The list of providers. - :type value: + :ivar value: The list of providers. + :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -281,10 +341,17 @@ class ProviderOperationsMetadataListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ProviderOperationsMetadata"]] = None, + value: Optional[List["_models.ProviderOperationsMetadata"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(ProviderOperationsMetadataListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -293,12 +360,13 @@ def __init__( class ResourceType(msrest.serialization.Model): """Resource Type. - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + :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 = { @@ -312,9 +380,18 @@ def __init__( *, name: Optional[str] = None, display_name: Optional[str] = None, - operations: Optional[List["ProviderOperation"]] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs ): + """ + :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(ResourceType, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -332,14 +409,14 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :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 = { @@ -367,6 +444,16 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :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(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -382,13 +469,13 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. 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. + :vartype principal_id: str + :ivar can_delegate: The delegation flag used for creating a role assignment. + :vartype can_delegate: bool """ _validation = { @@ -410,6 +497,15 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. 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. + :paramtype principal_id: str + :keyword can_delegate: The delegation flag used for creating a role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -419,10 +515,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :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 = { @@ -437,6 +533,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :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(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -445,10 +547,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -459,10 +561,16 @@ class RoleAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignment"]] = None, + value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -479,16 +587,16 @@ class RoleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The role definition type. :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[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 = { @@ -514,10 +622,22 @@ def __init__( role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, - permissions: Optional[List["Permission"]] = None, + permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs ): + """ + :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(RoleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -532,10 +652,10 @@ def __init__( class RoleDefinitionFilter(msrest.serialization.Model): """Role Definitions filter. - :param role_name: Returns role definition with the specific name. - :type role_name: str - :param type: Returns role definition with the specific type. - :type type: str + :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 = { @@ -550,6 +670,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(RoleDefinitionFilter, self).__init__(**kwargs) self.role_name = role_name self.type = type @@ -558,10 +684,10 @@ def __init__( class RoleDefinitionListResult(msrest.serialization.Model): """Role definition list operation result. - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -572,10 +698,16 @@ class RoleDefinitionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleDefinition"]] = None, + value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleDefinitionListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index be3e88f5724f..646069764687 100644 --- 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 @@ -11,9 +11,14 @@ from ._permissions_operations import PermissionsOperations from ._role_definitions_operations import RoleDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 5fcce526eb28..a181ce05cfd0 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,181 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class PermissionsOperations(object): - """PermissionsOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PermissionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.PermissionGetResult]: """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. :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,31 +189,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable[_models.PermissionGetResult]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,47 +233,59 @@ def list_for_resource( :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 PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PermissionGetResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -190,17 +294,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore 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 index 2331c9c04547..23393c30d399 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,165 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) -class ProviderOperationsMetadataOperations(object): - """ProviderOperationsMetadataOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - resource_provider_namespace, # type: str - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProviderOperationsMetadata" + resource_provider_namespace: str, + expand: Optional[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. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadata"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadata] + + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -103,54 +173,66 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProviderOperationsMetadataListResult"] + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> Iterable[_models.ProviderOperationsMetadataListResult]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :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 ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProviderOperationsMetadataListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -159,17 +241,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore 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 index 8ec1f2daa997..dbf53949405e 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,57 +6,437 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentsOperations(object): - """RoleAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + 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.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +451,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +519,91 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +612,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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. @@ -237,37 +650,39 @@ def delete( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +693,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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 @@ -297,52 +714,54 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +770,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -371,37 +792,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +833,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_id: str, + **kwargs: Any + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -427,36 +852,38 @@ def delete_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -467,61 +894,65 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **kwargs: Any + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -530,14 +961,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + **kwargs: Any + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -547,36 +980,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -585,60 +1020,70 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,76 +1092,89 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -725,17 +1183,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index 00fc742eda70..ac1bb1b8a9ae 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,236 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleDefinition] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleDefinitionsOperations(object): - """RoleDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def delete( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleDefinition"] + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -63,37 +247,39 @@ def delete( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleDefinition"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleDefinition]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -104,15 +290,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> _models.RoleDefinition: """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -124,37 +312,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -163,16 +353,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def create_or_update( self, - scope, # type: str - role_definition_id, # type: str - role_definition, # type: "_models.RoleDefinition" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + role_definition: _models.RoleDefinition, + **kwargs: Any + ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -186,42 +378,43 @@ def create_or_update( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] + + _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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -230,62 +423,72 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleDefinitionListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleDefinitionListResult]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + 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 RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,27 +497,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + 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, @@ -328,36 +536,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleDefinition] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -366,4 +576,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index ce546ece5311..bca230f59d2c 100644 --- 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 @@ -6,113 +6,133 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from . import models +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(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 5c9bd6311f43..7462e20ce1ec 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + 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.api_version = "2018-05-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2018_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json index e992c72e1e2d..a3bd4454d665 100644 --- 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 @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index 57640f36f638..6aeac812aebb 100644 --- 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 @@ -6,109 +6,133 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from .. import models +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(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index a07795ddc22a..b79d4cf39636 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + 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.api_version = "2018-05-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2018_05_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 9fe7178064d5..b430fe8f3b8e 100644 --- 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 @@ -16,6 +16,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'AccessReviewScheduleDefinitionsOperations', @@ -27,3 +30,5 @@ 'AccessReviewInstancesAssignedForMyApprovalOperations', 'AccessReviewInstanceMyDecisionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 13b6cb88ffe8..b31dd787919d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewDefaultSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, **kwargs: Any - ) -> "_models.AccessReviewDefaultSettings": + ) -> _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 @@ -51,36 +54,38 @@ async def get( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -89,57 +94,62 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async async def put( self, - properties: "_models.AccessReviewScheduleSettings", + properties: _models.AccessReviewScheduleSettings, **kwargs: Any - ) -> "_models.AccessReviewDefaultSettings": + ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -148,4 +158,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + 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 index e1a995a343de..d20549dd7e82 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceDecisionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -54,45 +57,55 @@ def list( :param id: The id of the access review instance. :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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +114,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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 index 22ab8981dbfd..2d95e3cfd8ae 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceMyDecisionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -54,44 +58,53 @@ def list( :param id: The id of the access review instance. :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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,28 +113,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> "_models.AccessReviewDecision": + ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -135,38 +154,40 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -175,16 +196,19 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, - properties: "_models.AccessReviewDecisionProperties", + properties: _models.AccessReviewDecisionProperties, **kwargs: Any - ) -> "_models.AccessReviewDecision": + ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -194,49 +218,51 @@ async def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -245,4 +271,6 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + 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 index 75c39ff8437c..c13a3359e70f 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,44 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - async def stop( + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -57,46 +60,50 @@ async def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - async def reset_decisions( + @distributed_trace_async + async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -113,46 +120,50 @@ async def reset_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - async def apply_decisions( + @distributed_trace_async + async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -169,46 +180,50 @@ async def apply_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore - async def send_reminders( + + @distributed_trace_async + async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -225,46 +240,50 @@ async def send_reminders( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + - async def accept_recommendations( + @distributed_trace_async + async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -281,40 +300,43 @@ async def accept_recommendations( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + 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 index fc9106f368c8..55824c084533 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,89 +6,100 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstancesAssignedForMyApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. :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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -96,27 +108,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> "_models.AccessReviewInstance": + ) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -128,37 +146,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -167,4 +187,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index 479d93c18f55..55df1b9cb861 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,102 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. :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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,27 +110,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> "_models.AccessReviewInstance": + ) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -129,38 +148,40 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -169,4 +190,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index 7d876ea7ecd4..b06b8cda2561 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,94 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: """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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +102,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore 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 index ede53b7fea6d..66152e835ec3 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,97 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewScheduleDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: """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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,26 +105,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, **kwargs: Any - ) -> "_models.AccessReviewScheduleDefinition": + ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -122,37 +140,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -161,9 +181,12 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -177,97 +200,103 @@ async def delete_by_id( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, - properties: "_models.AccessReviewScheduleDefinitionProperties", + properties: _models.AccessReviewScheduleDefinitionProperties, **kwargs: Any - ) -> "_models.AccessReviewScheduleDefinition": + ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -276,9 +305,12 @@ async def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -292,40 +324,43 @@ async def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + 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 index 1e2b098f9c7f..fb979df857ed 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,93 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +101,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 498d27291a3b..22d10423d9d1 100644 --- 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 @@ -6,46 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import AccessReviewDecision # type: ignore - from ._models import AccessReviewDecisionListResult # type: ignore - from ._models import AccessReviewDecisionProperties # type: ignore - from ._models import AccessReviewDecisionTarget # type: ignore - from ._models import AccessReviewDefaultSettings # type: ignore - from ._models import AccessReviewInstance # type: ignore - from ._models import AccessReviewInstanceListResult # type: ignore - from ._models import AccessReviewReviewer # type: ignore - from ._models import AccessReviewScheduleDefinition # type: ignore - from ._models import AccessReviewScheduleDefinitionListResult # type: ignore - from ._models import AccessReviewScheduleDefinitionProperties # type: ignore - from ._models import AccessReviewScheduleSettings # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import ServicePrincipalDecisionTarget # type: ignore - from ._models import UserDecisionTarget # type: ignore +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, @@ -62,7 +42,9 @@ DecisionTargetType, DefaultDecisionType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AccessReviewDecision', 'AccessReviewDecisionListResult', @@ -97,3 +79,5 @@ 'DecisionTargetType', 'DefaultDecisionType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index d00c500e2fa7..0c0f77fde9b5 100644 --- 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 @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +18,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The outcome of applying the decision. """ @@ -52,7 +36,7 @@ class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" APPLY_NOT_SUPPORTED = "ApplyNotSupported" -class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +52,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +67,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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 """ @@ -94,14 +78,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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. @@ -111,7 +95,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This read-only field specifies the status of an accessReview. """ @@ -127,21 +111,21 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type user/servicePrincipal to review """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This specifies the behavior for the autoReview feature when an access review completes. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py deleted file mode 100644 index a722a5bff820..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py +++ /dev/null @@ -1,1204 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessReviewDecision(msrest.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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type 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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "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. Possible values include: "user", "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. Possible values include: "user", "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 - :param type_properties_target_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type 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, - **kwargs - ): - super(AccessReviewDecision, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - 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 = None # type: Optional[str] - - -class AccessReviewDecisionListResult(msrest.serialization.Model): - """List of access review decisions. - - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewDecision]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewDecisionProperties(msrest.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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type 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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "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. - Possible values include: "user", "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. - Possible values include: "user", "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 - :param type: The type of decision target : User/ServicePrincipal.Constant filled by server. - Possible values include: "user", "servicePrincipal". - :type 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, - **kwargs - ): - super(AccessReviewDecisionProperties, self).__init__(**kwargs) - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - 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 = None # type: Optional[str] - - -class AccessReviewDecisionTarget(msrest.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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(AccessReviewDecisionTarget, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -class AccessReviewDefaultSettings(msrest.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 - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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, - **kwargs - ): - super(AccessReviewDefaultSettings, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_recurrence_range_type = kwargs.get('type_properties_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_recurrence_pattern_type = kwargs.get('type_properties_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class AccessReviewInstance(msrest.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. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type 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, - **kwargs - ): - super(AccessReviewInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - - -class AccessReviewInstanceListResult(msrest.serialization.Model): - """List of Access Review Instances. - - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewReviewer(msrest.serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "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, - **kwargs - ): - super(AccessReviewReviewer, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - - -class AccessReviewScheduleDefinition(msrest.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 - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type 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. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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. Possible values include: "user", "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__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_settings_recurrence_range_type = kwargs.get('type_properties_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_settings_recurrence_pattern_type = kwargs.get('type_properties_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): - """List of Access Review Schedule Definitions. - - :param value: Access Review Schedule Definition list. - :type value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewScheduleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type 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. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "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__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_settings_recurrence_range_type = kwargs.get('type_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_settings_recurrence_pattern_type = kwargs.get('type_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(msrest.serialization.Model): - """Settings of an Access Review. - - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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, - **kwargs - ): - super(AccessReviewScheduleSettings, self).__init__(**kwargs) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_recurrence_range_type = kwargs.get('type_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_recurrence_pattern_type = kwargs.get('type_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.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 - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type 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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(ServicePrincipalDecisionTarget, self).__init__(**kwargs) - self.type = 'servicePrincipal' # type: str - 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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(UserDecisionTarget, self).__init__(**kwargs) - self.type = 'user' # type: str - 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/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py index e833c4d6e9e0..f67b2192e0fc 100644 --- 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessReviewDecision(msrest.serialization.Model): @@ -26,21 +28,22 @@ class AccessReviewDecision(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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", "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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", + "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. @@ -48,7 +51,7 @@ class AccessReviewDecision(msrest.serialization.Model): :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -59,7 +62,7 @@ class AccessReviewDecision(msrest.serialization.Model): :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -67,10 +70,9 @@ class AccessReviewDecision(msrest.serialization.Model): :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 - :param type_properties_target_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type type_properties_target_type: str or + :ivar type_properties_target_type: The type of decision target : User/ServicePrincipal.Constant + filled by server. Known values are: "user", "servicePrincipal". + :vartype type_properties_target_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ @@ -116,10 +118,19 @@ class AccessReviewDecision(msrest.serialization.Model): def __init__( self, *, - decision: Optional[Union[str, "AccessReviewResult"]] = None, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", "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(AccessReviewDecision, self).__init__(**kwargs) self.id = None self.name = None @@ -144,10 +155,10 @@ def __init__( class AccessReviewDecisionListResult(msrest.serialization.Model): """List of access review decisions. - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -158,10 +169,17 @@ class AccessReviewDecisionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewDecision"]] = None, + value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewDecisionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -172,21 +190,22 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): 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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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", "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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", + "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. @@ -194,7 +213,7 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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. @@ -204,16 +223,16 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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 - :param type: The type of decision target : User/ServicePrincipal.Constant filled by server. - Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: The type of decision target : User/ServicePrincipal.Constant filled by server. + Known values are: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -252,10 +271,19 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): def __init__( self, *, - decision: Optional[Union[str, "AccessReviewResult"]] = None, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", "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(AccessReviewDecisionProperties, self).__init__(**kwargs) self.recommendation = None self.decision = decision @@ -282,9 +310,9 @@ class AccessReviewDecisionTarget(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -303,6 +331,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionTarget, self).__init__(**kwargs) self.type = None # type: Optional[str] @@ -319,50 +349,50 @@ class AccessReviewDefaultSettings(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :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", "numbered". + :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _validation = { @@ -398,18 +428,65 @@ def __init__( reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_properties_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewDefaultSettings, self).__init__(**kwargs) self.id = None self.name = None @@ -441,15 +518,15 @@ class AccessReviewInstance(msrest.serialization.Model): :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. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime + :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 = { @@ -475,6 +552,12 @@ def __init__( end_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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(AccessReviewInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -487,10 +570,10 @@ def __init__( class AccessReviewInstanceListResult(msrest.serialization.Model): """List of Access Review Instances. - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -501,10 +584,17 @@ class AccessReviewInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewInstance"]] = None, + value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -515,10 +605,10 @@ class AccessReviewReviewer(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". + :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", + "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewerType """ @@ -538,6 +628,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ super(AccessReviewReviewer, self).__init__(**kwargs) self.principal_id = principal_id self.principal_type = None @@ -554,87 +648,87 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :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. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". + assigned and instead be chosen dynamically. For example managers review or self review. Known + values are: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :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. Possible values include: "user", "servicePrincipal". + to review. Known values are: "user", "servicePrincipal". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :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", "numbered". + :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -698,24 +792,86 @@ def __init__( display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["AccessReviewReviewer"]] = None, - instances: Optional[List["AccessReviewInstance"]] = 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, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_properties_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", + "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", "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(AccessReviewScheduleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -753,11 +909,11 @@ def __init__( class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): """List of Access Review Schedule Definitions. - :param value: Access Review Schedule Definition list. - :type value: + :ivar value: Access Review Schedule Definition list. + :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -768,10 +924,17 @@ class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewScheduleDefinition"]] = None, + value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -782,87 +945,87 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :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. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". + assigned and instead be chosen dynamically. For example managers review or self review. Known + values are: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "servicePrincipal". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :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", "numbered". + :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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. @@ -920,24 +1083,85 @@ def __init__( display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["AccessReviewReviewer"]] = None, - instances: Optional[List["AccessReviewInstance"]] = 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, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) self.display_name = display_name self.status = None @@ -972,50 +1196,50 @@ def __init__( class AccessReviewScheduleSettings(msrest.serialization.Model): """Settings of an Access Review. - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :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", "numbered". + :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _attribute_map = { @@ -1042,18 +1266,65 @@ def __init__( reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewScheduleSettings, self).__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled @@ -1074,8 +1345,8 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -1085,9 +1356,14 @@ class ErrorDefinition(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDefinitionProperties"] = None, + error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -1099,8 +1375,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -1118,6 +1394,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -1126,14 +1406,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :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 = { @@ -1148,10 +1428,20 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs ): + """ + :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(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -1192,6 +1482,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1202,10 +1494,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :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 = { @@ -1216,10 +1508,16 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1232,9 +1530,9 @@ class ServicePrincipalDecisionTarget(AccessReviewDecisionTarget): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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. @@ -1261,6 +1559,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServicePrincipalDecisionTarget, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.principal_id = None @@ -1275,9 +1575,9 @@ class UserDecisionTarget(AccessReviewDecisionTarget): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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. @@ -1304,6 +1604,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserDecisionTarget, self).__init__(**kwargs) self.type = 'user' # type: str self.principal_id = 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 9fe7178064d5..b430fe8f3b8e 100644 --- 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 @@ -16,6 +16,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'AccessReviewScheduleDefinitionsOperations', @@ -27,3 +30,5 @@ 'AccessReviewInstancesAssignedForMyApprovalOperations', 'AccessReviewInstanceMyDecisionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 3825a6e7381e..b1411018cba8 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,124 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleSettings] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class AccessReviewDefaultSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewDefaultSettingsOperations(object): - """AccessReviewDefaultSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + **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 @@ -56,36 +131,38 @@ def get( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -94,58 +171,62 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace def put( self, - properties, # type: "_models.AccessReviewScheduleSettings" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -154,4 +235,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + 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 index 554fcef70f11..a1731d962d4d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,90 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceDecisionsOperations(object): - """AccessReviewInstanceDecisionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,45 +97,55 @@ def list( :param id: The id of the access review instance. :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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +154,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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 index 9f7048249338..f805f9c9a589 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,170 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewDecisionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstanceMyDecisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceMyDecisionsOperations(object): - """AccessReviewInstanceMyDecisionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,44 +177,53 @@ def list( :param id: The id of the access review instance. :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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,29 +232,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + 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. @@ -141,38 +273,40 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -181,17 +315,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace def patch( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - properties, # type: "_models.AccessReviewDecisionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -201,49 +337,51 @@ def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -252,4 +390,6 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + 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 index c9630800f4b7..69b67e615aaa 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,235 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceOperations(object): - """AccessReviewInstanceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -62,52 +246,55 @@ def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - def reset_decisions( + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -119,52 +306,55 @@ def reset_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore - def apply_decisions( + + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -176,52 +366,55 @@ def apply_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore - def send_reminders( + + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -233,52 +426,55 @@ def send_reminders( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + - def accept_recommendations( + @distributed_trace + def accept_recommendations( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -290,40 +486,43 @@ def accept_recommendations( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + 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 index 84f0ecf936a4..3d23ec0f2f82 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,170 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class AccessReviewInstancesAssignedForMyApprovalOperations(object): - """AccessReviewInstancesAssignedForMyApprovalOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AccessReviewInstancesAssignedForMyApprovalOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. :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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,28 +178,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + 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. @@ -134,37 +216,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -173,4 +257,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index d59e18077916..824967d98c0a 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,176 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class AccessReviewInstancesOperations(object): - """AccessReviewInstancesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AccessReviewInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. :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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,28 +184,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + 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. @@ -135,38 +222,40 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -175,4 +264,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index 9c137da7b56d..a38078027cd0 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,124 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): - """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: """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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +132,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore 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 index c66ac2cf646b..e1f5ffef37c1 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,280 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewScheduleDefinitionsOperations(object): - """AccessReviewScheduleDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: """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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,27 +288,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + 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. @@ -128,37 +323,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -167,14 +364,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -184,98 +383,103 @@ def delete_by_id( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace def create_or_update_by_id( self, - schedule_definition_id, # type: str - properties, # type: "_models.AccessReviewScheduleDefinitionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -284,14 +488,16 @@ def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -301,40 +507,43 @@ def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + 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 index 82a69202c8fc..06441bf21634 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,123 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +131,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index fe329ce394c1..133104781c62 100644 --- 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 @@ -6,73 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype deny_assignments: + azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 12ef59d35da0..4de2cccb8d38 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + 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.api_version = "2018-07-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2018_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json index 0666c785851c..39e7f82a0881 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index d2bb50dc9de8..04f65845702f 100644 --- 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 @@ -6,69 +6,86 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype deny_assignments: + azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index f2b03196299e..137b8de4b16b 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + 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.api_version = "2018-07-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2018_07_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 7b0c7bab2bcb..bd82f6dff80f 100644 --- 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 @@ -8,6 +8,11 @@ from ._deny_assignments_operations import DenyAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 index d18c4796ca47..d4800053100a 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """DenyAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -50,7 +54,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignmentListResult"]: + ) -> AsyncIterable[_models.DenyAssignmentListResult]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -72,53 +76,66 @@ def list_for_resource( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + 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, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + 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, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,27 +144,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignmentListResult"]: + ) -> AsyncIterable[_models.DenyAssignmentListResult]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -161,49 +184,58 @@ def list_for_resource_group( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -212,26 +244,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignmentListResult"]: + ) -> AsyncIterable[_models.DenyAssignmentListResult]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny @@ -243,48 +281,56 @@ def list( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,27 +339,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace_async async def get( self, scope: str, deny_assignment_id: str, **kwargs: Any - ) -> "_models.DenyAssignment": + ) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. @@ -325,37 +377,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -364,13 +418,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, deny_assignment_id: str, **kwargs: Any - ) -> "_models.DenyAssignment": + ) -> _models.DenyAssignment: """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, @@ -384,36 +441,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignment] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -422,14 +481,17 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{denyAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignmentListResult"]: + ) -> AsyncIterable[_models.DenyAssignmentListResult]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. @@ -443,48 +505,56 @@ def list_for_scope( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -493,17 +563,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 61272d33ee63..deef4270e45e 100644 --- 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 @@ -6,25 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import DenyAssignment # type: ignore - from ._models import DenyAssignmentFilter # type: ignore - from ._models import DenyAssignmentListResult # type: ignore - from ._models import DenyAssignmentPermission # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Principal # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DenyAssignment', 'DenyAssignmentFilter', @@ -35,3 +28,5 @@ 'ErrorResponse', 'Principal', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py deleted file mode 100644 index d3b3f6701114..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py +++ /dev/null @@ -1,290 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class DenyAssignment(msrest.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 - :param deny_assignment_name: The display name of the deny assignment. - :type deny_assignment_name: str - :param description: The description of the deny assignment. - :type description: str - :param permissions: An array of permissions that are denied by the deny assignment. - :type permissions: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] - :param scope: The deny assignment scope. - :type scope: str - :param do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. - Default value is false. - :type do_not_apply_to_child_scopes: bool - :param principals: Array of principals to which the deny assignment applies. - :type principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param exclude_principals: Array of principals to which the deny assignment does not apply. - :type exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :type 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, - **kwargs - ): - super(DenyAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.deny_assignment_name = kwargs.get('deny_assignment_name', None) - self.description = kwargs.get('description', None) - self.permissions = kwargs.get('permissions', None) - self.scope = kwargs.get('scope', None) - self.do_not_apply_to_child_scopes = kwargs.get('do_not_apply_to_child_scopes', None) - self.principals = kwargs.get('principals', None) - self.exclude_principals = kwargs.get('exclude_principals', None) - self.is_system_protected = kwargs.get('is_system_protected', None) - - -class DenyAssignmentFilter(msrest.serialization.Model): - """Deny Assignments filter. - - :param deny_assignment_name: Return deny assignment with specified name. - :type deny_assignment_name: str - :param principal_id: Return all deny assignments where the specified principal is listed in the - principals list of deny assignments. - :type principal_id: str - :param 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. - :type 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, - **kwargs - ): - super(DenyAssignmentFilter, self).__init__(**kwargs) - self.deny_assignment_name = kwargs.get('deny_assignment_name', None) - self.principal_id = kwargs.get('principal_id', None) - self.gdpr_export_principal_id = kwargs.get('gdpr_export_principal_id', None) - - -class DenyAssignmentListResult(msrest.serialization.Model): - """Deny assignment list operation result. - - :param value: Deny assignment list. - :type value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DenyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DenyAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DenyAssignmentPermission(msrest.serialization.Model): - """Deny assignment permissions. - - :param actions: Actions to which the deny assignment does not grant access. - :type actions: list[str] - :param not_actions: Actions to exclude from that the deny assignment does not grant access. - :type not_actions: list[str] - :param data_actions: Data actions to which the deny assignment does not grant access. - :type data_actions: list[str] - :param not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :type 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, - **kwargs - ): - super(DenyAssignmentPermission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Principal(msrest.serialization.Model): - """The name of the entity last modified it. - - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type 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, - **kwargs - ): - super(Principal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - self.email = kwargs.get('email', None) 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 index 50386332c7cd..a69bc47f72c3 100644 --- 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class DenyAssignment(msrest.serialization.Model): """Deny Assignment. @@ -23,25 +27,26 @@ class DenyAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The deny assignment type. :vartype type: str - :param deny_assignment_name: The display name of the deny assignment. - :type deny_assignment_name: str - :param description: The description of the deny assignment. - :type description: str - :param permissions: An array of permissions that are denied by the deny assignment. - :type permissions: + :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] - :param scope: The deny assignment scope. - :type scope: str - :param do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. + :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. - :type do_not_apply_to_child_scopes: bool - :param principals: Array of principals to which the deny assignment applies. - :type principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param exclude_principals: Array of principals to which the deny assignment does not apply. - :type exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param is_system_protected: Specifies whether this deny assignment was created by Azure and + :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. - :type is_system_protected: bool + :vartype is_system_protected: bool """ _validation = { @@ -69,14 +74,36 @@ def __init__( *, deny_assignment_name: Optional[str] = None, description: Optional[str] = None, - permissions: Optional[List["DenyAssignmentPermission"]] = None, + permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, scope: Optional[str] = None, do_not_apply_to_child_scopes: Optional[bool] = None, - principals: Optional[List["Principal"]] = None, - exclude_principals: Optional[List["Principal"]] = None, + principals: Optional[List["_models.Principal"]] = None, + exclude_principals: Optional[List["_models.Principal"]] = None, is_system_protected: Optional[bool] = None, **kwargs ): + """ + :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(DenyAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -94,14 +121,14 @@ def __init__( class DenyAssignmentFilter(msrest.serialization.Model): """Deny Assignments filter. - :param deny_assignment_name: Return deny assignment with specified name. - :type deny_assignment_name: str - :param principal_id: Return all deny assignments where the specified principal is listed in the + :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. - :type principal_id: str - :param gdpr_export_principal_id: Return all deny assignments where the specified principal is + :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. - :type gdpr_export_principal_id: str + :vartype gdpr_export_principal_id: str """ _attribute_map = { @@ -118,6 +145,16 @@ def __init__( gdpr_export_principal_id: Optional[str] = None, **kwargs ): + """ + :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(DenyAssignmentFilter, self).__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id @@ -127,10 +164,10 @@ def __init__( class DenyAssignmentListResult(msrest.serialization.Model): """Deny assignment list operation result. - :param value: Deny assignment list. - :type value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -141,10 +178,16 @@ class DenyAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DenyAssignment"]] = None, + value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(DenyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -153,15 +196,15 @@ def __init__( class DenyAssignmentPermission(msrest.serialization.Model): """Deny assignment permissions. - :param actions: Actions to which the deny assignment does not grant access. - :type actions: list[str] - :param not_actions: Actions to exclude from that the deny assignment does not grant access. - :type not_actions: list[str] - :param data_actions: Data actions to which the deny assignment does not grant access. - :type data_actions: list[str] - :param not_data_actions: Data actions to exclude from that the deny assignment does not grant + :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. - :type not_data_actions: list[str] + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -180,6 +223,17 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :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(DenyAssignmentPermission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -212,6 +266,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -255,6 +311,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -266,8 +324,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ _attribute_map = { @@ -277,9 +335,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -287,14 +349,14 @@ def __init__( class Principal(msrest.serialization.Model): """The name of the entity last modified it. - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str + :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 = { @@ -313,6 +375,16 @@ def __init__( email: Optional[str] = None, **kwargs ): + """ + :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(Principal, self).__init__(**kwargs) self.id = id self.display_name = display_name 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 7b0c7bab2bcb..bd82f6dff80f 100644 --- 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 @@ -8,6 +8,11 @@ from ._deny_assignments_operations import DenyAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 index 1c22aa2904b1..c162759895b9 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,57 +6,285 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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( + subscription_id: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + resource_group_name: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DenyAssignmentsOperations(object): - """DenyAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_07_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + 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.DenyAssignmentListResult]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -77,53 +306,66 @@ def list_for_resource( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + 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, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + 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, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,28 +374,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DenyAssignmentListResult]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -167,49 +414,58 @@ def list_for_resource_group( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -218,27 +474,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DenyAssignmentListResult]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny @@ -250,48 +511,56 @@ def list( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -300,28 +569,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - deny_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DenyAssignment" + scope: str, + deny_assignment_id: str, + **kwargs: Any + ) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. @@ -333,37 +607,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -372,14 +648,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - deny_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DenyAssignment" + 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, @@ -393,36 +671,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignment] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -431,15 +711,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{denyAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DenyAssignmentListResult]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. @@ -453,48 +735,56 @@ def list_for_scope( 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. + 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 DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DenyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -503,17 +793,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 44241ef6b928..9d0fec7d5b0c 100644 --- 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 @@ -6,73 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype role_assignments: + azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 4733e535b56d..48129d62ee8e 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + 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.api_version = "2018-09-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2018_09_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json index bdd80a44a1a9..8f666e6ab321 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index 72b80ff6ea12..2cb17a6d0036 100644 --- 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 @@ -6,69 +6,85 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype role_assignments: + azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index 73519a2fc10d..66cd0153d49a 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + 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.api_version = "2018-09-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2018_09_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index b9e31fd2db90..f860d08de6a1 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignments_operations import RoleAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 0d07516a09a1..a16a4517ad19 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -50,7 +54,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,53 +69,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,76 +137,91 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,27 +230,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -230,37 +268,39 @@ async def delete( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,15 +311,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -289,52 +332,54 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,14 +388,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -362,37 +410,39 @@ async def get( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,13 +451,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -417,36 +470,38 @@ async def delete_by_id( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -457,60 +512,65 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -519,13 +579,16 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -535,36 +598,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -573,59 +638,70 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,75 +710,89 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -711,17 +801,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index 83bed7401315..bb8467d95879 100644 --- 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 @@ -6,27 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ErrorAdditionalInfo', 'ErrorDetail', @@ -37,3 +31,5 @@ 'RoleAssignmentListResult', 'PrincipalType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index c60129f05bca..bfdadaf80be7 100644 --- 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 @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principal type of the assigned principal ID. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py deleted file mode 100644 index e7eec8469933..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py +++ /dev/null @@ -1,247 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignment(msrest.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 - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type 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, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type 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, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) 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 index a6dbf45a8abe..887f5a199c52 100644 --- 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorAdditionalInfo(msrest.serialization.Model): @@ -39,6 +41,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -82,6 +86,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -93,8 +99,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ _attribute_map = { @@ -104,9 +110,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -122,17 +132,18 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :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". + :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 = { @@ -158,10 +169,24 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs ): + """ + :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", "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(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -178,16 +203,17 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. 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. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "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 = { @@ -207,10 +233,23 @@ def __init__( *, role_definition_id: str, principal_id: str, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. 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. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "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(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -221,10 +260,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :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 = { @@ -239,6 +278,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :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(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -247,10 +292,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -261,10 +306,16 @@ class RoleAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignment"]] = None, + value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index b9e31fd2db90..f860d08de6a1 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignments_operations import RoleAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 5c0f8f71739b..30490afc79d0 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,57 +6,437 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentsOperations(object): - """RoleAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2018_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + 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.RoleAssignmentListResult]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +451,66 @@ def list_for_resource( :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +519,91 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +612,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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. @@ -237,37 +650,39 @@ def delete( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +693,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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 @@ -297,52 +714,54 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +770,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -371,37 +792,39 @@ def get( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +833,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_id: str, + **kwargs: Any + ) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -427,36 +852,38 @@ def delete_by_id( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -467,61 +894,65 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **kwargs: Any + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -530,14 +961,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + **kwargs: Any + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -547,36 +980,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -585,60 +1020,70 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,76 +1092,89 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -725,17 +1183,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 7f4540945cef..e058290845ad 100644 --- 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 @@ -6,73 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype role_assignment_metrics: + azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index b98b95f68dae..2bddcf93739f 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + 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.api_version = "2019-08-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2019_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json index 9fc9a49ce493..1a0942f5657c 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index c8cbf3acbd4e..0d2cec9f00d8 100644 --- 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 @@ -6,69 +6,85 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index c57152d3d991..34fbbbf7e817 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + 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.api_version = "2019-08-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2019_08_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 8244630e3d3d..1e448c4faa35 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignment_metrics_operations import RoleAssignmentMetricsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 62dd285c0dbf..fb56d18cda6b 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentMetricsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2019_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get_metrics_for_subscription( self, **kwargs: Any - ) -> "_models.RoleAssignmentMetricsResult": + ) -> _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 @@ -51,36 +54,38 @@ async def get_metrics_for_subscription( :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentMetricsResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_metrics_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentMetricsResult] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentMetricsResult', pipeline_response) @@ -89,4 +94,6 @@ async def get_metrics_for_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_metrics_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics'} # type: ignore + + get_metrics_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics"} # type: ignore + 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 index 300a963b2dfb..95608a34c006 100644 --- 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 @@ -6,20 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import RoleAssignmentMetricsResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignmentMetricsResult # type: ignore +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 * # type: ignore # 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() \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py deleted file mode 100644 index 90b847f06ec7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignmentMetricsResult(msrest.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: long - :ivar role_assignments_current_count: The number of current role assignments. - :vartype role_assignments_current_count: long - :ivar role_assignments_remaining_count: The number of remaining role assignments available. - :vartype role_assignments_remaining_count: long - """ - - _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': 'long'}, - 'role_assignments_current_count': {'key': 'roleAssignmentsCurrentCount', 'type': 'long'}, - 'role_assignments_remaining_count': {'key': 'roleAssignmentsRemainingCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentMetricsResult, self).__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/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py index 286bd07d2b43..4710f118fc3b 100644 --- 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Optional +from typing import Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. @@ -37,6 +41,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +86,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +99,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ _attribute_map = { @@ -102,9 +110,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -142,6 +154,8 @@ def __init__( self, **kwargs ): + """ + """ super(RoleAssignmentMetricsResult, self).__init__(**kwargs) self.subscription_id = None self.role_assignments_limit = 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 8244630e3d3d..1e448c4faa35 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignment_metrics_operations import RoleAssignmentMetricsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 454ef3be9b16..c60ded6ed7f0 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,83 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentMetricsOperations(object): - """RoleAssignmentMetricsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2019_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get_metrics_for_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentMetricsResult" + **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 @@ -56,36 +90,38 @@ def get_metrics_for_subscription( :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentMetricsResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_metrics_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentMetricsResult] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentMetricsResult', pipeline_response) @@ -94,4 +130,6 @@ def get_metrics_for_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_metrics_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics'} # type: ignore + + get_metrics_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics"} # type: ignore + 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 33609c807ffa..b34af4eebd3a 100644 --- 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 @@ -6,73 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype role_assignments: + azure.mgmt.authorization.v2020_04_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 68f02c44c0d2..50f7048797d0 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + 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.api_version = "2020-04-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2020_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json index 2343e9faff44..fa7c085931f6 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index e4d7629bf932..58757ce36733 100644 --- 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 @@ -6,69 +6,85 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """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. +class AuthorizationManagementClient: + """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 + :vartype role_assignments: + azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index 7ded355a0326..ab60c7ee2e73 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + 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.api_version = "2020-04-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2020_04_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index b9e31fd2db90..f860d08de6a1 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignments_operations import RoleAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 1dcb19f36287..7464cd44b893 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_04_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -51,7 +55,7 @@ def list_for_resource( filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,57 +70,70 @@ def list_for_resource( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,81 +142,96 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @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.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,74 +240,81 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. :type scope: str :param role_assignment_name: The name of the role assignment to delete. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -286,15 +325,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -304,52 +346,54 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -358,61 +402,65 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. :type scope: str :param role_assignment_name: The name of the role assignment to get. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -421,57 +469,61 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -482,60 +534,65 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -544,57 +601,61 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -603,64 +664,75 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -669,80 +741,94 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -751,17 +837,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 index 83bed7401315..bb8467d95879 100644 --- 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 @@ -6,27 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore +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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ErrorAdditionalInfo', 'ErrorDetail', @@ -37,3 +31,5 @@ 'RoleAssignmentListResult', 'PrincipalType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index c60129f05bca..bfdadaf80be7 100644 --- 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 @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principal type of the assigned principal ID. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py deleted file mode 100644 index 538c4b092fee..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py +++ /dev/null @@ -1,301 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignment(msrest.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 - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: Time it was created. - :type created_on: ~datetime.datetime - :param updated_on: Time it was updated. - :type updated_on: ~datetime.datetime - :param created_by: Id of the user who created the assignment. - :type created_by: str - :param updated_by: Id of the user who updated the assignment. - :type updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type 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, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.created_by = kwargs.get('created_by', None) - self.updated_by = kwargs.get('updated_by', None) - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type 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, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) 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 index e16a85d38810..cfc043dff1fb 100644 --- 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorAdditionalInfo(msrest.serialization.Model): @@ -40,6 +42,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -83,6 +87,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -94,8 +100,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ _attribute_map = { @@ -105,9 +111,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -123,36 +133,37 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :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". + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: Time it was created. - :type created_on: ~datetime.datetime - :param updated_on: Time it was updated. - :type updated_on: ~datetime.datetime - :param created_by: Id of the user who created the assignment. - :type created_by: str - :param updated_by: Id of the user who updated the assignment. - :type updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :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 = { @@ -186,7 +197,7 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, @@ -198,6 +209,39 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :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", "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(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -222,27 +266,28 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. 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. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. 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. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :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 = { @@ -266,7 +311,7 @@ def __init__( *, role_definition_id: str, principal_id: str, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, @@ -274,6 +319,30 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. 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. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "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(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -288,10 +357,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :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 = { @@ -306,6 +375,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :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(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -314,10 +389,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -328,10 +403,16 @@ class RoleAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignment"]] = None, + value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index b9e31fd2db90..f860d08de6a1 100644 --- 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 @@ -8,6 +8,11 @@ from ._role_assignments_operations import RoleAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index b6b21369439f..18ba1e5a3813 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,58 +6,466 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentsOperations(object): - """RoleAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_04_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - parent_resource_path, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + 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.RoleAssignmentListResult]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -71,57 +480,70 @@ def list_for_resource( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,82 +552,96 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -214,75 +650,81 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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. :type scope: str :param role_assignment_name: The name of the role assignment to delete. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -293,16 +735,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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 @@ -312,52 +756,54 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -366,62 +812,65 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + 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. :type scope: str :param role_assignment_name: The name of the role assignment to get. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -430,58 +879,61 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -492,61 +944,65 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **kwargs: Any + ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -555,58 +1011,61 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + 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. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -615,65 +1074,75 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -682,81 +1151,94 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -765,17 +1247,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore 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 new file mode 100644 index 000000000000..d9033c6b26a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py @@ -0,0 +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. +# 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 * # type: ignore # 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 new file mode 100644 index 000000000000..b755fdfbd268 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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=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. + :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(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 + ) + 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 + ) + + + 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/python/protocol/quickstart + + :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): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AuthorizationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..c953ef181762 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + :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 = kwargs.pop('api_version', "2020-10-01") # type: str + + 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 # type: Any + ): + # type: (...) -> 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 new file mode 100644 index 000000000000..0b794e4af545 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json @@ -0,0 +1,98 @@ +{ + "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": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 = "1.0.0b1" 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 new file mode 100644 index 000000000000..069a548e077c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..b991dca36c33 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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=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. + :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(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 + ) + 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 + ) + + + 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/python/protocol/quickstart + + :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) -> 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 new file mode 100644 index 000000000000..cc2e871193fb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +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. + :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 = kwargs.pop('api_version', "2020-10-01") # type: str + + 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..35c8e1f53b9a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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/v2020_10_01/aio/operations/_eligible_child_resources_operations.py new file mode 100644 index 000000000000..8379a40fcc02 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py @@ -0,0 +1,135 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @distributed_trace + def get( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.EligibleChildResourcesListResult]: + """Get the child resources of a resource on which user has eligible access. + + :param scope: The scope of the role management policy. + :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 EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EligibleChildResourcesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py new file mode 100644 index 000000000000..5f07125fa402 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py @@ -0,0 +1,201 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleAssignmentScheduleInstanceListResult]: + """Gets role assignment schedule instances of a role assignment schedule. + + :param scope: The scope of the role assignment schedule. + :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 RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the + role assignment schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py new file mode 100644 index 000000000000..8354c0fcafc3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py @@ -0,0 +1,406 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.v2020_10_01.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") + + + @distributed_trace_async + async def create( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: _models.RoleAssignmentScheduleRequest, + **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 '/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. + :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. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @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. + :type scope: str + :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule + request to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleAssignmentScheduleRequestListResult]: + """Gets role assignment schedule requests for a scope. + + :param scope: The scope of the role assignments schedule requests. + :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 RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequestListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + cancel. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace_async + async def validate( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: _models.RoleAssignmentScheduleRequest, + **kwargs: Any + ) -> _models.RoleAssignmentScheduleRequest: + """Validates a new role assignment schedule request. + + :param scope: The scope of the role assignment request to validate. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + validate. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py new file mode 100644 index 000000000000..04fe5eabbef3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py @@ -0,0 +1,200 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @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. + :type scope: str + :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentSchedule] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleAssignmentScheduleListResult]: + """Gets role assignment schedules for a resource scope. + + :param scope: The scope of the role assignments schedules. + :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 RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py new file mode 100644 index 000000000000..0ca0127a7393 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -0,0 +1,201 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleEligibilityScheduleInstanceListResult]: + """Gets role eligibility schedule instances of a role eligibility schedule. + + :param scope: The scope of the role eligibility schedule. + :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 RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the + role eligibility schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py new file mode 100644 index 000000000000..407cffd7595d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -0,0 +1,406 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.v2020_10_01.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") + + + @distributed_trace_async + async def create( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: _models.RoleEligibilityScheduleRequest, + **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 '/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. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It + can be any valid GUID. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @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. + :type scope: str + :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule + request to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleEligibilityScheduleRequestListResult]: + """Gets role eligibility schedule requests for a scope. + + :param scope: The scope of the role eligibility schedule requests. + :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 RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequestListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + cancel. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace_async + async def validate( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: _models.RoleEligibilityScheduleRequest, + **kwargs: Any + ) -> _models.RoleEligibilityScheduleRequest: + """Validates a new role eligibility schedule request. + + :param scope: The scope of the role eligibility request to validate. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + validate. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py new file mode 100644 index 000000000000..943212214d3b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py @@ -0,0 +1,200 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @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. + :type scope: str + :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilitySchedule] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleEligibilityScheduleListResult]: + """Gets role eligibility schedules for a resource scope. + + :param scope: The scope of the role eligibility schedules. + :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 RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2020_10_01/aio/operations/_role_management_policies_operations.py new file mode 100644 index 000000000000..0b84d72d0756 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py @@ -0,0 +1,317 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @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. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + scope: str, + role_management_policy_name: str, + parameters: _models.RoleManagementPolicy, + **kwargs: Any + ) -> _models.RoleManagementPolicy: + """Update a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_name: str + :param parameters: Parameters for the role management policy. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + _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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> AsyncIterable[_models.RoleManagementPolicyListResult]: + """Gets role management policies for a resource scope. + + :param scope: The scope of the role management policy. + :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 RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py new file mode 100644 index 000000000000..3cd8d6b58089 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py @@ -0,0 +1,320 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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") + + + @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. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + scope: str, + role_management_policy_assignment_name: str, + parameters: _models.RoleManagementPolicyAssignment, + **kwargs: Any + ) -> _models.RoleManagementPolicyAssignment: + """Create a role management policy assignment. + + :param scope: The scope of the role management policy assignment to upsert. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to upsert. + :type role_management_policy_assignment_name: str + :param parameters: Parameters for the role management policy assignment. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # 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: + """Delete a role management policy assignment. + + :param scope: The scope of the role management policy assignment to delete. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to delete. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> AsyncIterable[_models.RoleManagementPolicyAssignmentListResult]: + """Gets role management assignment policies for a resource scope. + + :param scope: The scope of the role management policy. + :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 RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignmentListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..125d151e7bd9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py @@ -0,0 +1,151 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, + AssignmentType, + EnablementRules, + MemberType, + NotificationDeliveryMechanism, + NotificationLevel, + PrincipalType, + RecipientType, + RequestType, + RoleManagementPolicyRuleType, + Status, + Type, + UserType, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..86ee85bdeb45 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 new file mode 100644 index 000000000000..722b3ba5d7eb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py @@ -0,0 +1,3119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 List, Optional, TYPE_CHECKING, Union + +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class ApprovalSettings(msrest.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", + "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 + ): + """ + :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", "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(ApprovalSettings, self).__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(msrest.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 + ): + """ + :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(ApprovalStage, self).__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(msrest.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 + ): + """ + :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(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + + +class EligibleChildResource(msrest.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 + ): + """ + """ + super(EligibleChildResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class EligibleChildResourcesListResult(msrest.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 + ): + """ + :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(EligibleChildResourcesListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ExpandedProperties(msrest.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 + ): + """ + :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(ExpandedProperties, self).__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.principal = principal + + +class ExpandedPropertiesPrincipal(msrest.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, + display_name: Optional[str] = None, + email: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(ExpandedPropertiesPrincipal, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.email = email + self.type = type + + +class ExpandedPropertiesRoleDefinition(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class ExpandedPropertiesScope(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(ExpandedPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Permission(msrest.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 + ): + """ + :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(Permission, self).__init__(**kwargs) + self.actions = actions + self.not_actions = not_actions + self.data_actions = data_actions + self.not_data_actions = not_data_actions + + +class PolicyAssignmentProperties(msrest.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 + ): + """ + :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(PolicyAssignmentProperties, self).__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.policy = policy + + +class PolicyAssignmentPropertiesPolicy(msrest.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, + last_modified_date_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :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(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) + self.id = id + self.last_modified_by = None + self.last_modified_date_time = last_modified_date_time + + +class PolicyAssignmentPropertiesRoleDefinition(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyAssignmentPropertiesScope(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyProperties(msrest.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 + ): + """ + """ + super(PolicyProperties, self).__init__(**kwargs) + self.scope = None + + +class PolicyPropertiesScope(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :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(PolicyPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Principal(msrest.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, + display_name: Optional[str] = None, + type: Optional[str] = None, + email: Optional[str] = None, + **kwargs + ): + """ + :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(Principal, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + self.email = email + + +class RoleAssignmentSchedule(msrest.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", "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", "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", "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", "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 + ): + """ + :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", "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", "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", "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", "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(RoleAssignmentSchedule, self).__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(msrest.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 + ): + """ + :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(RoleAssignmentScheduleFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleAssignmentScheduleInstance(msrest.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", "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", "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", "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", "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 + ): + """ + :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", "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", "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", "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", "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(RoleAssignmentScheduleInstance, self).__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(msrest.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 + ): + """ + :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(RoleAssignmentScheduleInstanceFilter, self).__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(msrest.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 + ): + """ + :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(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleListResult(msrest.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 + ): + """ + :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(RoleAssignmentScheduleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequest(msrest.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", "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", "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", "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 + ): + """ + :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", "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(RoleAssignmentScheduleRequest, self).__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(msrest.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 + ): + """ + :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(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleAssignmentScheduleRequestListResult(msrest.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 + ): + """ + :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(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.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 + ): + """ + :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(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): + """Expiration of the role assignment schedule. + + :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", + "AfterDateTime", "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 + ): + """ + :keyword type: Type of the role assignment schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", "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(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.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 + ): + """ + :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(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleEligibilitySchedule(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(RoleEligibilitySchedule, self).__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(msrest.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 + ): + """ + :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(RoleEligibilityScheduleFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleEligibilityScheduleInstance(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(RoleEligibilityScheduleInstance, self).__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(msrest.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 + ): + """ + :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(RoleEligibilityScheduleInstanceFilter, self).__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(msrest.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 + ): + """ + :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(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleListResult(msrest.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 + ): + """ + :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(RoleEligibilityScheduleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequest(msrest.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", "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", "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", "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 + ): + """ + :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", "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(RoleEligibilityScheduleRequest, self).__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(msrest.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 + ): + """ + :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(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleEligibilityScheduleRequestListResult(msrest.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 + ): + """ + :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(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.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 + ): + """ + :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(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): + """Expiration of the role eligibility schedule. + + :ivar type: Type of the role eligibility schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", "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 + ): + """ + :keyword type: Type of the role eligibility schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", "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(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.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 + ): + """ + :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(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleManagementPolicy(msrest.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.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 + ): + """ + :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(RoleManagementPolicy, self).__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(msrest.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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + **kwargs + ): + """ + :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(RoleManagementPolicyRule, self).__init__(**kwargs) + self.id = id + self.rule_type = None # type: Optional[str] + 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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + setting: Optional["_models.ApprovalSettings"] = None, + **kwargs + ): + """ + :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(RoleManagementPolicyApprovalRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str + self.setting = setting + + +class RoleManagementPolicyAssignment(msrest.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 + ): + """ + :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(RoleManagementPolicyAssignment, self).__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(msrest.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 + ): + """ + :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(RoleManagementPolicyAssignmentListResult, self).__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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + is_enabled: Optional[bool] = None, + claim_value: Optional[str] = None, + **kwargs + ): + """ + :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(RoleManagementPolicyAuthenticationContextRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str + 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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, + **kwargs + ): + """ + :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(RoleManagementPolicyEnablementRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str + 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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + is_expiration_required: Optional[bool] = None, + maximum_duration: Optional[str] = None, + **kwargs + ): + """ + :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(RoleManagementPolicyExpirationRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str + self.is_expiration_required = is_expiration_required + self.maximum_duration = maximum_duration + + +class RoleManagementPolicyListResult(msrest.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 + ): + """ + :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(RoleManagementPolicyListResult, self).__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: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "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. Known values are: "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", "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", "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, + 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 + ): + """ + :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. Known values are: "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", + "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", + "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(RoleManagementPolicyNotificationRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str + 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(msrest.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 + ): + """ + :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(RoleManagementPolicyRuleTarget, self).__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(msrest.serialization.Model): + """The detail of a user. + + :ivar user_type: The type of user. Known values are: "User", "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, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword user_type: The type of user. Known values are: "User", "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(UserSet, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..35c8e1f53b9a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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/v2020_10_01/operations/_eligible_child_resources_operations.py new file mode 100644 index 000000000000..c46df4de35d3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py @@ -0,0 +1,175 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @distributed_trace + def get( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.EligibleChildResourcesListResult]: + """Get the child resources of a resource on which user has eligible access. + + :param scope: The scope of the role management policy. + :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 EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EligibleChildResourcesListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py new file mode 100644 index 000000000000..82f1ec814b78 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py @@ -0,0 +1,275 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleInstanceListResult]: + """Gets role assignment schedule instances of a role assignment schedule. + + :param scope: The scope of the role assignment schedule. + :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 RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the + role assignment schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py new file mode 100644 index 000000000000..34b3ab48ca8e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py @@ -0,0 +1,601 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + *, + json: Optional[_models.RoleAssignmentScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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.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") + + + @distributed_trace + def create( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: _models.RoleAssignmentScheduleRequest, + **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 '/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. + :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. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @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. + :type scope: str + :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule + request to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleRequestListResult]: + """Gets role assignment schedule requests for a scope. + + :param scope: The scope of the role assignments schedule requests. + :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 RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequestListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + cancel. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace + def validate( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: _models.RoleAssignmentScheduleRequest, + **kwargs: Any + ) -> _models.RoleAssignmentScheduleRequest: + """Validates a new role assignment schedule request. + + :param scope: The scope of the role assignment request to validate. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + validate. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/operations/_role_assignment_schedules_operations.py new file mode 100644 index 000000000000..5c55965d8c38 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py @@ -0,0 +1,274 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @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. + :type scope: str + :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentSchedule] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleListResult]: + """Gets role assignment schedules for a resource scope. + + :param scope: The scope of the role assignments schedules. + :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 RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py new file mode 100644 index 000000000000..7f237c45b1c9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py @@ -0,0 +1,275 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleInstanceListResult]: + """Gets role eligibility schedule instances of a role eligibility schedule. + + :param scope: The scope of the role eligibility schedule. + :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 RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the + role eligibility schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py new file mode 100644 index 000000000000..bff093794df3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py @@ -0,0 +1,601 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + *, + json: Optional[_models.RoleEligibilityScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleEligibilityScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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.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") + + + @distributed_trace + def create( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: _models.RoleEligibilityScheduleRequest, + **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 '/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. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It + can be any valid GUID. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @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. + :type scope: str + :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule + request to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleRequestListResult]: + """Gets role eligibility schedule requests for a scope. + + :param scope: The scope of the role eligibility schedule requests. + :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 RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequestListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + cancel. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace + def validate( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: _models.RoleEligibilityScheduleRequest, + **kwargs: Any + ) -> _models.RoleEligibilityScheduleRequest: + """Validates a new role eligibility schedule request. + + :param scope: The scope of the role eligibility request to validate. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + validate. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2020_10_01/operations/_role_eligibility_schedules_operations.py new file mode 100644 index 000000000000..f039aa8b7950 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py @@ -0,0 +1,274 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @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. + :type scope: str + :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilitySchedule] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleListResult]: + """Gets role eligibility schedules for a resource scope. + + :param scope: The scope of the role eligibility schedules. + :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 RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2020_10_01/operations/_role_management_policies_operations.py new file mode 100644 index 000000000000..63497360fe9a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py @@ -0,0 +1,465 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleManagementPolicy] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @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. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def update( + self, + scope: str, + role_management_policy_name: str, + parameters: _models.RoleManagementPolicy, + **kwargs: Any + ) -> _models.RoleManagementPolicy: + """Update a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_name: str + :param parameters: Parameters for the role management policy. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + _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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> Iterable[_models.RoleManagementPolicyListResult]: + """Gets role management policies for a resource scope. + + :param scope: The scope of the role management policy. + :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 RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2020_10_01/operations/_role_management_policy_assignments_operations.py new file mode 100644 index 000000000000..6a7469965b0b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py @@ -0,0 +1,468 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleManagementPolicyAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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.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") + + + @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. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to get. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def create( + self, + scope: str, + role_management_policy_assignment_name: str, + parameters: _models.RoleManagementPolicyAssignment, + **kwargs: Any + ) -> _models.RoleManagementPolicyAssignment: + """Create a role management policy assignment. + + :param scope: The scope of the role management policy assignment to upsert. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to upsert. + :type role_management_policy_assignment_name: str + :param parameters: Parameters for the role management policy assignment. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @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. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to delete. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> Iterable[_models.RoleManagementPolicyAssignmentListResult]: + """Gets role management assignment policies for a resource scope. + + :param scope: The scope of the role management policy. + :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 RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignmentListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed @@ -0,0 +1 @@ +# 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index ea267e40412d..b7b76fc6c347 100644 --- 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 @@ -6,118 +6,140 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations -from .operations import EligibleChildResourcesOperations -from .operations import RoleAssignmentSchedulesOperations -from .operations import RoleAssignmentScheduleInstancesOperations -from .operations import RoleAssignmentScheduleRequestsOperations -from .operations import RoleEligibilitySchedulesOperations -from .operations import RoleEligibilityScheduleInstancesOperations -from .operations import RoleEligibilityScheduleRequestsOperations -from .operations import RoleManagementPoliciesOperations -from .operations import RoleManagementPolicyAssignmentsOperations from . import models +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(object): - """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. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 9e18c0b43993..835ade9777b0 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + 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.api_version = "2020-10-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2020_10_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json index bd67cca3e126..3455dc399fbc 100644 --- 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 @@ -5,13 +5,13 @@ "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.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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_10_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index a1de37eddf53..39737b5077a5 100644 --- 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 @@ -6,114 +6,140 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations -from .operations import EligibleChildResourcesOperations -from .operations import RoleAssignmentSchedulesOperations -from .operations import RoleAssignmentScheduleInstancesOperations -from .operations import RoleAssignmentScheduleRequestsOperations -from .operations import RoleEligibilitySchedulesOperations -from .operations import RoleEligibilityScheduleInstancesOperations -from .operations import RoleEligibilityScheduleRequestsOperations -from .operations import RoleManagementPoliciesOperations -from .operations import RoleManagementPolicyAssignmentsOperations from .. import models +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(object): - """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. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index 9977bad5f6d4..cc3cf3432cf3 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + 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.api_version = "2020-10-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2020_10_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 97e8639830c2..a8e937e9bdb8 100644 --- 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 @@ -17,6 +17,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'RoleAssignmentsOperations', 'EligibleChildResourcesOperations', @@ -29,3 +32,5 @@ 'RoleManagementPoliciesOperations', 'RoleManagementPolicyAssignmentsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 61bbae50ecc7..45ca060ce902 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """EligibleChildResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EligibleChildResourcesListResult"]: + ) -> AsyncIterable[_models.EligibleChildResourcesListResult]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. @@ -54,48 +57,56 @@ def get( :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'. + 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 EligibleChildResourcesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EligibleChildResourcesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,7 +115,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,7 +128,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/eligibleChildResources'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 3efcc5ed2bdf..94109992a1da 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentScheduleInstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleInstanceListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentScheduleInstanceListResult]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. @@ -56,48 +60,56 @@ def list_for_scope( 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. + 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 RoleAssignmentScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,17 +131,19 @@ 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/roleAssignmentScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any - ) -> "_models.RoleAssignmentScheduleInstance": + ) -> _models.RoleAssignmentScheduleInstance: """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. @@ -138,32 +156,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleInstanceName': self._serialize.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,4 +196,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + 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 index d5c1a38e36bd..db20149fb574 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentScheduleRequestsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: "_models.RoleAssignmentScheduleRequest", + parameters: _models.RoleAssignmentScheduleRequest, **kwargs: Any - ) -> "_models.RoleAssignmentScheduleRequest": + ) -> _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 @@ -58,47 +62,49 @@ async def create( '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment to create. It can - be any valid GUID. + :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. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -111,14 +117,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> "_models.RoleAssignmentScheduleRequest": + ) -> _models.RoleAssignmentScheduleRequest: """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. @@ -131,32 +140,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,14 +180,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleRequestListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentScheduleRequestListResult]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. @@ -187,48 +201,56 @@ def list_for_scope( 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. + 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 RoleAssignmentScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequestListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -237,7 +259,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,12 +272,14 @@ 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/roleAssignmentScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore - async def cancel( + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, @@ -269,32 +297,34 @@ async def cancel( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,4 +334,5 @@ async def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + 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 index 0a60be766dc9..37b6ea02a72a 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentSchedulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_name: str, **kwargs: Any - ) -> "_models.RoleAssignmentSchedule": + ) -> _models.RoleAssignmentSchedule: """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. @@ -58,32 +62,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleName': self._serialize.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentSchedule] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,14 +102,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentScheduleListResult]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. @@ -113,47 +122,56 @@ def list_for_scope( 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 RoleAssignmentScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,7 +180,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,7 +193,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore 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 index 9e0bb270be85..f79afb42675c 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,109 @@ # 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, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,81 +117,96 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @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.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """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. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,21 +215,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -212,7 +245,7 @@ def list_for_resource( filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -226,56 +259,68 @@ def list_for_resource( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,28 +329,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -315,46 +366,47 @@ async def get( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -363,15 +415,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _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: @@ -382,48 +437,50 @@ async def create( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -436,15 +493,18 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> 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: @@ -454,46 +514,47 @@ async def delete( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -504,15 +565,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def validate( self, scope: str, role_assignment_name: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.ValidationResponse": + ) -> _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: @@ -523,48 +587,50 @@ async def validate( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ValidationResponse] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -573,15 +639,18 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate'} # type: ignore + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentListResult]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -591,52 +660,60 @@ def list_for_scope( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -645,27 +722,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -673,45 +756,46 @@ async def get_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -720,14 +804,17 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.RoleAssignment": + ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -736,47 +823,49 @@ async def create_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -789,14 +878,17 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.RoleAssignment"]: + ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -804,45 +896,46 @@ async def delete_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -853,14 +946,17 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def validate_by_id( self, role_assignment_id: str, - parameters: "_models.RoleAssignmentCreateParameters", + parameters: _models.RoleAssignmentCreateParameters, **kwargs: Any - ) -> "_models.ValidationResponse": + ) -> _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, @@ -869,47 +965,49 @@ async def validate_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ValidationResponse] + + _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, + template_url=self.validate_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -918,4 +1016,6 @@ async def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - validate_by_id.metadata = {'url': '/{roleAssignmentId}/validate'} # type: ignore + + validate_by_id.metadata = {'url': "/{roleAssignmentId}/validate"} # type: ignore + 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 index 87f2bc311b3e..84324e204b6d 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleEligibilityScheduleInstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleInstanceListResult"]: + ) -> AsyncIterable[_models.RoleEligibilityScheduleInstanceListResult]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. @@ -56,47 +60,56 @@ def list_for_scope( 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 RoleEligibilityScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,17 +131,19 @@ 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/roleEligibilityScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any - ) -> "_models.RoleEligibilityScheduleInstance": + ) -> _models.RoleEligibilityScheduleInstance: """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. @@ -137,32 +156,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleInstanceName': self._serialize.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,4 +196,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + 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 index fced3034ad24..3ae9f02bc94c 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleEligibilityScheduleRequestsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: "_models.RoleEligibilityScheduleRequest", + parameters: _models.RoleEligibilityScheduleRequest, **kwargs: Any - ) -> "_models.RoleEligibilityScheduleRequest": + ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be @@ -62,43 +66,45 @@ async def create( can be any valid GUID. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -111,14 +117,17 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> "_models.RoleEligibilityScheduleRequest": + ) -> _models.RoleEligibilityScheduleRequest: """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. @@ -131,32 +140,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,14 +180,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleRequestListResult"]: + ) -> AsyncIterable[_models.RoleEligibilityScheduleRequestListResult]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. @@ -187,48 +201,56 @@ def list_for_scope( 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. + 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 RoleEligibilityScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequestListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -237,7 +259,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,12 +272,14 @@ 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/roleEligibilityScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore - async def cancel( + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, @@ -269,32 +297,34 @@ async def cancel( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,4 +334,5 @@ async def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + 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 index d97827812dde..b43abb3bad98 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleEligibilitySchedulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any - ) -> "_models.RoleEligibilitySchedule": + ) -> _models.RoleEligibilitySchedule: """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. @@ -58,32 +62,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilitySchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleName': self._serialize.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilitySchedule] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,14 +102,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleListResult"]: + ) -> AsyncIterable[_models.RoleEligibilityScheduleListResult]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. @@ -113,47 +122,56 @@ def list_for_scope( 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 RoleEligibilityScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,7 +180,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,7 +193,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore 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 index be9e97db7259..7923a770a067 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, scope: str, role_management_policy_name: str, **kwargs: Any - ) -> "_models.RoleManagementPolicy": + ) -> _models.RoleManagementPolicy: """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. @@ -58,32 +62,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,15 +102,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async async def update( self, scope: str, role_management_policy_name: str, - parameters: "_models.RoleManagementPolicy", + parameters: _models.RoleManagementPolicy, **kwargs: Any - ) -> "_models.RoleManagementPolicy": + ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. @@ -118,37 +127,38 @@ async def update( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + _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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,9 +171,12 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore - async def delete( + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, @@ -180,32 +193,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -215,55 +230,65 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, **kwargs: Any - ) -> AsyncIterable["_models.RoleManagementPolicyListResult"]: + ) -> AsyncIterable[_models.RoleManagementPolicyListResult]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. :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 RoleManagementPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,7 +297,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,7 +310,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore 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 index c43bf1591ab9..22002cc8c691 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleManagementPolicyAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> "_models.RoleManagementPolicyAssignment": + ) -> _models.RoleManagementPolicyAssignment: """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. @@ -59,32 +63,34 @@ async def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,15 +103,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: "_models.RoleManagementPolicyAssignment", + parameters: _models.RoleManagementPolicyAssignment, **kwargs: Any - ) -> "_models.RoleManagementPolicyAssignment": + ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. @@ -114,43 +123,45 @@ async def create( management policy assignment to upsert. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -163,9 +174,12 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore - async def delete( + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, @@ -183,32 +197,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -218,55 +234,65 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, **kwargs: Any - ) -> AsyncIterable["_models.RoleManagementPolicyAssignmentListResult"]: + ) -> AsyncIterable[_models.RoleManagementPolicyAssignmentListResult]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. :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 RoleManagementPolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -275,7 +301,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,7 +314,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore 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 index 7455c3e0a86b..b8b97cbe83a4 100644 --- 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 @@ -6,132 +6,69 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ApprovalSettings # type: ignore - from ._models import ApprovalStage # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import EligibleChildResource # type: ignore - from ._models import EligibleChildResourcesListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExpandedProperties # type: ignore - from ._models import ExpandedPropertiesPrincipal # type: ignore - from ._models import ExpandedPropertiesRoleDefinition # type: ignore - from ._models import ExpandedPropertiesScope # type: ignore - from ._models import Permission # type: ignore - from ._models import PolicyAssignmentProperties # type: ignore - from ._models import PolicyAssignmentPropertiesPolicy # type: ignore - from ._models import PolicyAssignmentPropertiesRoleDefinition # type: ignore - from ._models import PolicyAssignmentPropertiesScope # type: ignore - from ._models import PolicyProperties # type: ignore - from ._models import PolicyPropertiesScope # type: ignore - from ._models import Principal # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleAssignmentSchedule # type: ignore - from ._models import RoleAssignmentScheduleFilter # type: ignore - from ._models import RoleAssignmentScheduleInstance # type: ignore - from ._models import RoleAssignmentScheduleInstanceFilter # type: ignore - from ._models import RoleAssignmentScheduleInstanceListResult # type: ignore - from ._models import RoleAssignmentScheduleListResult # type: ignore - from ._models import RoleAssignmentScheduleRequest # type: ignore - from ._models import RoleAssignmentScheduleRequestFilter # type: ignore - from ._models import RoleAssignmentScheduleRequestListResult # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesScheduleInfo # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesTicketInfo # type: ignore - from ._models import RoleEligibilitySchedule # type: ignore - from ._models import RoleEligibilityScheduleFilter # type: ignore - from ._models import RoleEligibilityScheduleInstance # type: ignore - from ._models import RoleEligibilityScheduleInstanceFilter # type: ignore - from ._models import RoleEligibilityScheduleInstanceListResult # type: ignore - from ._models import RoleEligibilityScheduleListResult # type: ignore - from ._models import RoleEligibilityScheduleRequest # type: ignore - from ._models import RoleEligibilityScheduleRequestFilter # type: ignore - from ._models import RoleEligibilityScheduleRequestListResult # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesScheduleInfo # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesTicketInfo # type: ignore - from ._models import RoleManagementPolicy # type: ignore - from ._models import RoleManagementPolicyApprovalRule # type: ignore - from ._models import RoleManagementPolicyAssignment # type: ignore - from ._models import RoleManagementPolicyAssignmentListResult # type: ignore - from ._models import RoleManagementPolicyAuthenticationContextRule # type: ignore - from ._models import RoleManagementPolicyEnablementRule # type: ignore - from ._models import RoleManagementPolicyExpirationRule # type: ignore - from ._models import RoleManagementPolicyListResult # type: ignore - from ._models import RoleManagementPolicyNotificationRule # type: ignore - from ._models import RoleManagementPolicyRule # type: ignore - from ._models import RoleManagementPolicyRuleTarget # type: ignore - from ._models import UserSet # type: ignore - from ._models import ValidationResponse # type: ignore - from ._models import ValidationResponseErrorInfo # type: ignore +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, @@ -148,7 +85,9 @@ Type, UserType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ApprovalSettings', 'ApprovalStage', @@ -226,3 +165,5 @@ 'Type', 'UserType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index d6415a11e6d4..37b6dad9bd53 100644 --- 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 @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule """ @@ -35,14 +19,14 @@ class ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARALLEL = "Parallel" NO_APPROVAL = "NoApproval" -class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Assignment type of the role assignment schedule """ ACTIVATED = "Activated" ASSIGNED = "Assigned" -class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of enable rules """ @@ -50,7 +34,7 @@ class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): JUSTIFICATION = "Justification" TICKETING = "Ticketing" -class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Membership type of the role assignment schedule """ @@ -58,13 +42,13 @@ class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DIRECT = "Direct" GROUP = "Group" -class NotificationDeliveryMechanism(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of notification. """ EMAIL = "Email" -class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The notification level. """ @@ -72,7 +56,7 @@ class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CRITICAL = "Critical" ALL = "All" -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principal type of the assigned principal ID. """ @@ -82,7 +66,7 @@ class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FOREIGN_GROUP = "ForeignGroup" DEVICE = "Device" -class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recipient type. """ @@ -90,7 +74,7 @@ class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPROVER = "Approver" ADMIN = "Admin" -class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc """ @@ -104,7 +88,7 @@ class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SELF_EXTEND = "SelfExtend" SELF_RENEW = "SelfRenew" -class RoleManagementPolicyRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule """ @@ -114,7 +98,7 @@ class RoleManagementPolicyRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the role assignment schedule. """ @@ -141,7 +125,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SCHEDULE_CREATED = "ScheduleCreated" PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the role assignment schedule expiration """ @@ -149,7 +133,7 @@ class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AFTER_DATE_TIME = "AfterDateTime" NO_EXPIRATION = "NoExpiration" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of user. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py deleted file mode 100644 index b4ab4b9b7c44..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py +++ /dev/null @@ -1,2581 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ApprovalSettings(msrest.serialization.Model): - """The approval settings. - - :param is_approval_required: Determine whether approval is required or not. - :type is_approval_required: bool - :param is_approval_required_for_extension: Determine whether approval is required for - assignment extension. - :type is_approval_required_for_extension: bool - :param is_requestor_justification_required: Determine whether requestor justification required. - :type is_requestor_justification_required: bool - :param approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", - "Parallel", "NoApproval". - :type approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :param approval_stages: The approval stages of the request. - :type 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, - **kwargs - ): - super(ApprovalSettings, self).__init__(**kwargs) - self.is_approval_required = kwargs.get('is_approval_required', None) - self.is_approval_required_for_extension = kwargs.get('is_approval_required_for_extension', None) - self.is_requestor_justification_required = kwargs.get('is_requestor_justification_required', None) - self.approval_mode = kwargs.get('approval_mode', None) - self.approval_stages = kwargs.get('approval_stages', None) - - -class ApprovalStage(msrest.serialization.Model): - """The approval stage. - - :param approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :type approval_stage_time_out_in_days: int - :param is_approver_justification_required: Determine whether approver need to provide - justification for his decision. - :type is_approver_justification_required: bool - :param escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approves. - :type escalation_time_in_minutes: int - :param primary_approvers: The primary approver of the request. - :type primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :param is_escalation_enabled: The value determine whether escalation feature is enabled. - :type is_escalation_enabled: bool - :param escalation_approvers: The escalation approver of the request. - :type 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, - **kwargs - ): - super(ApprovalStage, self).__init__(**kwargs) - self.approval_stage_time_out_in_days = kwargs.get('approval_stage_time_out_in_days', None) - self.is_approver_justification_required = kwargs.get('is_approver_justification_required', None) - self.escalation_time_in_minutes = kwargs.get('escalation_time_in_minutes', None) - self.primary_approvers = kwargs.get('primary_approvers', None) - self.is_escalation_enabled = kwargs.get('is_escalation_enabled', None) - self.escalation_approvers = kwargs.get('escalation_approvers', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class EligibleChildResource(msrest.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 - ): - super(EligibleChildResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class EligibleChildResourcesListResult(msrest.serialization.Model): - """Eligible child resources list operation result. - - :param value: Eligible child resource list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EligibleChildResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EligibleChildResourcesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.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 - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.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.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExpandedProperties(msrest.serialization.Model): - """ExpandedProperties. - - :param scope: Details of the resource scope. - :type scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition - :param principal: Details of the principal. - :type 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, - **kwargs - ): - super(ExpandedProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition = kwargs.get('role_definition', None) - self.principal = kwargs.get('principal', None) - - -class ExpandedPropertiesPrincipal(msrest.serialization.Model): - """Details of the principal. - - :param id: Id of the principal. - :type id: str - :param display_name: Display name of the principal. - :type display_name: str - :param email: Email id of the principal. - :type email: str - :param type: Type of the principal. - :type 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, - **kwargs - ): - super(ExpandedPropertiesPrincipal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.email = kwargs.get('email', None) - self.type = kwargs.get('type', None) - - -class ExpandedPropertiesRoleDefinition(msrest.serialization.Model): - """Details of role definition. - - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class ExpandedPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type 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, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -class PolicyAssignmentProperties(msrest.serialization.Model): - """PolicyAssignmentProperties. - - :param scope: Details of the resource scope. - :type scope: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :param policy: Details of the policy. - :type 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, - **kwargs - ): - super(PolicyAssignmentProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition = kwargs.get('role_definition', None) - self.policy = kwargs.get('policy', None) - - -class PolicyAssignmentPropertiesPolicy(msrest.serialization.Model): - """Details of the policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Id of the policy. - :type 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 - :param last_modified_date_time: The last modified date time. - :type 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, - **kwargs - ): - super(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.last_modified_by = None - self.last_modified_date_time = kwargs.get('last_modified_date_time', None) - - -class PolicyAssignmentPropertiesRoleDefinition(msrest.serialization.Model): - """Details of role definition. - - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class PolicyAssignmentPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class PolicyProperties(msrest.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 - ): - super(PolicyProperties, self).__init__(**kwargs) - self.scope = None - - -class PolicyPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class Principal(msrest.serialization.Model): - """The name of the entity last modified it. - - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type 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, - **kwargs - ): - super(Principal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - self.email = kwargs.get('email', None) - - -class RoleAssignment(msrest.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 - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type 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 - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type 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, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentCreateParameters(msrest.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 Azure. - - :ivar scope: The role assignment scope. - :vartype scope: str - :param role_definition_id: Required. The role definition ID. - :type role_definition_id: str - :param principal_id: Required. The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type 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 - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type 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, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.scope = None - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role assignment list. - :type 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, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentSchedule(msrest.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 - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :type role_assignment_schedule_request_id: str - :param linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated - this roleAssignmentSchedule. - :type linked_role_eligibility_schedule_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role assignment schedule. Possible values include: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role assignment schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role assignment schedule. - :type end_date_time: ~datetime.datetime - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role assignment schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type 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, - **kwargs - ): - super(RoleAssignmentSchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_assignment_schedule_request_id = kwargs.get('role_assignment_schedule_request_id', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.assignment_type = kwargs.get('assignment_type', None) - self.member_type = kwargs.get('member_type', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleAssignmentScheduleFilter(msrest.serialization.Model): - """Role assignment schedule filter. - - :param principal_id: Returns role assignment schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - - -class RoleAssignmentScheduleInstance(msrest.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 - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_id: Id of the master role assignment schedule. - :type role_assignment_schedule_id: str - :param origin_role_assignment_id: Role Assignment Id in external system. - :type origin_role_assignment_id: str - :param status: The status of the role assignment schedule instance. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role assignment schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role assignment schedule instance. - :type end_date_time: ~datetime.datetime - :param linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :type linked_role_eligibility_schedule_id: str - :param linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :type linked_role_eligibility_schedule_instance_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_assignment_schedule_id = kwargs.get('role_assignment_schedule_id', None) - self.origin_role_assignment_id = kwargs.get('origin_role_assignment_id', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.linked_role_eligibility_schedule_instance_id = kwargs.get('linked_role_eligibility_schedule_instance_id', None) - self.assignment_type = kwargs.get('assignment_type', None) - self.member_type = kwargs.get('member_type', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleAssignmentScheduleInstanceFilter(msrest.serialization.Model): - """Role assignment schedule instance filter. - - :param principal_id: Returns role assignment schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str - :param role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleInstanceFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - self.role_assignment_schedule_id = kwargs.get('role_assignment_schedule_id', None) - - -class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): - """Role assignment schedule instance list operation result. - - :param value: Role assignment schedule instance list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleListResult(msrest.serialization.Model): - """Role assignment schedule list operation result. - - :param value: Role assignment schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleRequest(msrest.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 - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: - "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role assignment schedule request. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :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 - :param target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :type target_role_assignment_schedule_id: str - :param target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :type target_role_assignment_schedule_instance_id: str - :param schedule_info: Schedule info of the role assignment schedule. - :type schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :param linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :type linked_role_eligibility_schedule_id: str - :param justification: Justification for the role assignment. - :type justification: str - :param ticket_info: Ticket Info of the role assignment. - :type ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleRequest, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - self.request_type = kwargs.get('request_type', None) - self.status = None - self.approval_id = None - self.target_role_assignment_schedule_id = kwargs.get('target_role_assignment_schedule_id', None) - self.target_role_assignment_schedule_instance_id = kwargs.get('target_role_assignment_schedule_instance_id', None) - self.schedule_info = kwargs.get('schedule_info', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.justification = kwargs.get('justification', None) - self.ticket_info = kwargs.get('ticket_info', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleAssignmentScheduleRequestFilter(msrest.serialization.Model): - """Role assignment schedule request filter. - - :param principal_id: Returns role assignment requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role assignment requests created by specific principal. - :type requestor_id: str - :param status: Returns role assignment requests of specific status. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.requestor_id = kwargs.get('requestor_id', None) - self.status = kwargs.get('status', None) - - -class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): - """Role assignment schedule request list operation result. - - :param value: Role assignment schedule request list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleRequest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): - """Schedule info of the role assignment schedule. - - :param start_date_time: Start DateTime of the role assignment schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role assignment schedule. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) - self.start_date_time = kwargs.get('start_date_time', None) - self.expiration = kwargs.get('expiration', None) - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): - """Expiration of the role assignment schedule. - - :param type: Type of the role assignment schedule expiration. Possible values include: - "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role assignment schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role assignment schedule in TimeSpan. - :type 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, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.duration = kwargs.get('duration', None) - - -class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): - """Ticket Info of the role assignment. - - :param ticket_number: Ticket number for the role assignment. - :type ticket_number: str - :param ticket_system: Ticket system name for the role assignment. - :type ticket_system: str - """ - - _attribute_map = { - 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, - 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) - self.ticket_number = kwargs.get('ticket_number', None) - self.ticket_system = kwargs.get('ticket_system', None) - - -class RoleEligibilitySchedule(msrest.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 - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :type role_eligibility_schedule_request_id: str - :param member_type: Membership type of the role eligibility schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role eligibility schedule. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role eligibility schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type 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, - **kwargs - ): - super(RoleEligibilitySchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_eligibility_schedule_request_id = kwargs.get('role_eligibility_schedule_request_id', None) - self.member_type = kwargs.get('member_type', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleEligibilityScheduleFilter(msrest.serialization.Model): - """Role eligibility schedule filter. - - :param principal_id: Returns role eligibility schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule of the specific status. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - - -class RoleEligibilityScheduleInstance(msrest.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 - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_id: Id of the master role eligibility schedule. - :type role_eligibility_schedule_id: str - :param status: The status of the role eligibility schedule instance. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role eligibility schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role eligibility schedule instance. - :type end_date_time: ~datetime.datetime - :param member_type: Membership type of the role eligibility schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_eligibility_schedule_id = kwargs.get('role_eligibility_schedule_id', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.member_type = kwargs.get('member_type', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleEligibilityScheduleInstanceFilter(msrest.serialization.Model): - """Role eligibility schedule instance filter. - - :param principal_id: Returns role eligibility schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule instances of the specific status. - :type status: str - :param role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a - specific role eligibility schedule. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleInstanceFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - self.role_eligibility_schedule_id = kwargs.get('role_eligibility_schedule_id', None) - - -class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): - """Role eligibility schedule instance list operation result. - - :param value: Role eligibility schedule instance list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleListResult(msrest.serialization.Model): - """role eligibility schedule list operation result. - - :param value: role eligibility schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilitySchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleRequest(msrest.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 - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: - "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role eligibility schedule request. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :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 - :param schedule_info: Schedule info of the role eligibility schedule. - :type schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :param target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :type target_role_eligibility_schedule_id: str - :param target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id - being updated. - :type target_role_eligibility_schedule_instance_id: str - :param justification: Justification for the role eligibility. - :type justification: str - :param ticket_info: Ticket Info of the role eligibility. - :type ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :param 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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleRequest, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - self.request_type = kwargs.get('request_type', None) - self.status = None - self.approval_id = None - self.schedule_info = kwargs.get('schedule_info', None) - self.target_role_eligibility_schedule_id = kwargs.get('target_role_eligibility_schedule_id', None) - self.target_role_eligibility_schedule_instance_id = kwargs.get('target_role_eligibility_schedule_instance_id', None) - self.justification = kwargs.get('justification', None) - self.ticket_info = kwargs.get('ticket_info', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleEligibilityScheduleRequestFilter(msrest.serialization.Model): - """Role eligibility schedule request filter. - - :param principal_id: Returns role eligibility requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role eligibility requests created by specific principal. - :type requestor_id: str - :param status: Returns role eligibility requests of specific status. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.requestor_id = kwargs.get('requestor_id', None) - self.status = kwargs.get('status', None) - - -class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): - """Role eligibility schedule request list operation result. - - :param value: Role eligibility schedule request list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleRequest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): - """Schedule info of the role eligibility schedule. - - :param start_date_time: Start DateTime of the role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role eligibility schedule. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) - self.start_date_time = kwargs.get('start_date_time', None) - self.expiration = kwargs.get('expiration', None) - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): - """Expiration of the role eligibility schedule. - - :param type: Type of the role eligibility schedule expiration. Possible values include: - "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role eligibility schedule in TimeSpan. - :type 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, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.duration = kwargs.get('duration', None) - - -class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): - """Ticket Info of the role eligibility. - - :param ticket_number: Ticket number for the role eligibility. - :type ticket_number: str - :param ticket_system: Ticket system name for the role eligibility. - :type ticket_system: str - """ - - _attribute_map = { - 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, - 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) - self.ticket_number = kwargs.get('ticket_number', None) - self.ticket_system = kwargs.get('ticket_system', None) - - -class RoleManagementPolicy(msrest.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 - :param scope: The role management policy scope. - :type scope: str - :param display_name: The role management policy display name. - :type display_name: str - :param description: The role management policy description. - :type description: str - :param is_organization_default: The role management policy is default policy. - :type 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 - :param rules: The rule applied to the policy. - :type 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, - **kwargs - ): - super(RoleManagementPolicy, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.is_organization_default = kwargs.get('is_organization_default', None) - self.last_modified_by = None - self.last_modified_date_time = None - self.rules = kwargs.get('rules', None) - self.effective_rules = None - self.policy_properties = None - - -class RoleManagementPolicyRule(msrest.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. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type 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, - **kwargs - ): - super(RoleManagementPolicyRule, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.rule_type = None # type: Optional[str] - self.target = kwargs.get('target', None) - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param setting: The approval setting. - :type 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, - **kwargs - ): - super(RoleManagementPolicyApprovalRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str - self.setting = kwargs.get('setting', None) - - -class RoleManagementPolicyAssignment(msrest.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 - :param scope: The role management policy scope. - :type scope: str - :param role_definition_id: The role definition of management policy assignment. - :type role_definition_id: str - :param policy_id: The policy id role management policy assignment. - :type 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, - **kwargs - ): - super(RoleManagementPolicyAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.policy_id = kwargs.get('policy_id', None) - self.policy_assignment_properties = None - - -class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): - """Role management policy assignment list operation result. - - :param value: Role management policy assignment list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleManagementPolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_enabled: The value indicating if rule is enabled. - :type is_enabled: bool - :param claim_value: The claim value. - :type 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, - **kwargs - ): - super(RoleManagementPolicyAuthenticationContextRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str - self.is_enabled = kwargs.get('is_enabled', None) - self.claim_value = kwargs.get('claim_value', None) - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param enabled_rules: The list of enabled rules. - :type 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, - **kwargs - ): - super(RoleManagementPolicyEnablementRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str - self.enabled_rules = kwargs.get('enabled_rules', None) - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_expiration_required: The value indicating whether expiration is required. - :type is_expiration_required: bool - :param maximum_duration: The maximum duration of expiration in timespan. - :type 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, - **kwargs - ): - super(RoleManagementPolicyExpirationRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str - self.is_expiration_required = kwargs.get('is_expiration_required', None) - self.maximum_duration = kwargs.get('maximum_duration', None) - - -class RoleManagementPolicyListResult(msrest.serialization.Model): - """Role management policy list operation result. - - :param value: Role management policy list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleManagementPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param notification_type: The type of notification. Possible values include: "Email". - :type notification_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :param notification_level: The notification level. Possible values include: "None", "Critical", - "All". - :type notification_level: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :param recipient_type: The recipient type. Possible values include: "Requestor", "Approver", - "Admin". - :type recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :param notification_recipients: The list notification recipients. - :type notification_recipients: list[str] - :param is_default_recipients_enabled: Its value determine if the notification need to be sent - to the recipient type specified in policy rule. - :type 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, - **kwargs - ): - super(RoleManagementPolicyNotificationRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str - self.notification_type = kwargs.get('notification_type', None) - self.notification_level = kwargs.get('notification_level', None) - self.recipient_type = kwargs.get('recipient_type', None) - self.notification_recipients = kwargs.get('notification_recipients', None) - self.is_default_recipients_enabled = kwargs.get('is_default_recipients_enabled', None) - - -class RoleManagementPolicyRuleTarget(msrest.serialization.Model): - """The role management policy rule target. - - :param caller: The caller of the setting. - :type caller: str - :param operations: The type of operation. - :type operations: list[str] - :param level: The assignment level to which it is applied. - :type level: str - :param target_objects: The list of target objects. - :type target_objects: list[str] - :param inheritable_settings: The list of inheritable settings. - :type inheritable_settings: list[str] - :param enforced_settings: The list of enforced settings. - :type 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, - **kwargs - ): - super(RoleManagementPolicyRuleTarget, self).__init__(**kwargs) - self.caller = kwargs.get('caller', None) - self.operations = kwargs.get('operations', None) - self.level = kwargs.get('level', None) - self.target_objects = kwargs.get('target_objects', None) - self.inheritable_settings = kwargs.get('inheritable_settings', None) - self.enforced_settings = kwargs.get('enforced_settings', None) - - -class UserSet(msrest.serialization.Model): - """The detail of a user. - - :param user_type: The type of user. Possible values include: "User", "Group". - :type user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :param is_backup: The value indicating whether the user is a backup fallback approver. - :type is_backup: bool - :param id: The object id of the user. - :type id: str - :param description: The description of the user. - :type 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, - **kwargs - ): - super(UserSet, self).__init__(**kwargs) - self.user_type = kwargs.get('user_type', None) - self.is_backup = kwargs.get('is_backup', None) - self.id = kwargs.get('id', None) - self.description = kwargs.get('description', None) - - -class ValidationResponse(msrest.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 - :param error_info: Failed validation result details. - :type 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, - **kwargs - ): - super(ValidationResponse, self).__init__(**kwargs) - self.is_valid = None - self.error_info = kwargs.get('error_info', None) - - -class ValidationResponseErrorInfo(msrest.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 - ): - super(ValidationResponseErrorInfo, self).__init__(**kwargs) - self.code = None - self.message = None 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 index f56a5d95927c..8ffa94275448 100644 --- 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 @@ -7,29 +7,33 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ApprovalSettings(msrest.serialization.Model): """The approval settings. - :param is_approval_required: Determine whether approval is required or not. - :type is_approval_required: bool - :param is_approval_required_for_extension: Determine whether approval is required for - assignment extension. - :type is_approval_required_for_extension: bool - :param is_requestor_justification_required: Determine whether requestor justification required. - :type is_requestor_justification_required: bool - :param approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", - "Parallel", "NoApproval". - :type approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :param approval_stages: The approval stages of the request. - :type approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] + :ivar is_approval_required: Determine whether approval is required or not. + :vartype is_approval_required: bool + :ivar is_approval_required_for_extension: Determine whether approval is required for assignment + extension. + :vartype is_approval_required_for_extension: bool + :ivar is_requestor_justification_required: Determine whether requestor justification required. + :vartype is_requestor_justification_required: bool + :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", + "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 = { @@ -46,10 +50,27 @@ def __init__( 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, "ApprovalMode"]] = None, - approval_stages: Optional[List["ApprovalStage"]] = None, + approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, + approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs ): + """ + :keyword is_approval_required: Determine whether approval is required or not. + :paramtype is_approval_required: bool + :keyword is_approval_required_for_extension: Determine whether approval is required for + assignment extension. + :paramtype is_approval_required_for_extension: bool + :keyword is_requestor_justification_required: Determine whether requestor justification + required. + :paramtype is_requestor_justification_required: bool + :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", + "Parallel", "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(ApprovalSettings, self).__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension @@ -61,21 +82,22 @@ def __init__( class ApprovalStage(msrest.serialization.Model): """The approval stage. - :param approval_stage_time_out_in_days: The time in days when approval request would be timed + :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. - :type approval_stage_time_out_in_days: int - :param is_approver_justification_required: Determine whether approver need to provide + :vartype approval_stage_time_out_in_days: int + :ivar is_approver_justification_required: Determine whether approver need to provide justification for his decision. - :type is_approver_justification_required: bool - :param escalation_time_in_minutes: The time in minutes when the approval request would be + :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 approves. - :type escalation_time_in_minutes: int - :param primary_approvers: The primary approver of the request. - :type primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :param is_escalation_enabled: The value determine whether escalation feature is enabled. - :type is_escalation_enabled: bool - :param escalation_approvers: The escalation approver of the request. - :type escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] + :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 = { @@ -93,11 +115,30 @@ def __init__( 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["UserSet"]] = None, + primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, - escalation_approvers: Optional[List["UserSet"]] = None, + escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs ): + """ + :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: Determine 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 approves. + :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(ApprovalStage, self).__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required @@ -110,12 +151,12 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str + :vartype message: str """ _attribute_map = { @@ -130,6 +171,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :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(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -164,6 +213,8 @@ def __init__( self, **kwargs ): + """ + """ super(EligibleChildResource, self).__init__(**kwargs) self.id = None self.name = None @@ -173,10 +224,11 @@ def __init__( class EligibleChildResourcesListResult(msrest.serialization.Model): """Eligible child resources list operation result. - :param value: Eligible child resource list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -187,10 +239,17 @@ class EligibleChildResourcesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["EligibleChildResource"]] = None, + value: Optional[List["_models.EligibleChildResource"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(EligibleChildResourcesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -221,6 +280,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -264,6 +325,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -275,8 +338,8 @@ def __init__( class ErrorResponse(msrest.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.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ _attribute_map = { @@ -286,9 +349,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -296,13 +363,13 @@ def __init__( class ExpandedProperties(msrest.serialization.Model): """ExpandedProperties. - :param scope: Details of the resource scope. - :type scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: + :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 - :param principal: Details of the principal. - :type principal: + :ivar principal: Details of the principal. + :vartype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ @@ -315,11 +382,21 @@ class ExpandedProperties(msrest.serialization.Model): def __init__( self, *, - scope: Optional["ExpandedPropertiesScope"] = None, - role_definition: Optional["ExpandedPropertiesRoleDefinition"] = None, - principal: Optional["ExpandedPropertiesPrincipal"] = None, + scope: Optional["_models.ExpandedPropertiesScope"] = None, + role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, + principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, **kwargs ): + """ + :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(ExpandedProperties, self).__init__(**kwargs) self.scope = scope self.role_definition = role_definition @@ -329,14 +406,14 @@ def __init__( class ExpandedPropertiesPrincipal(msrest.serialization.Model): """Details of the principal. - :param id: Id of the principal. - :type id: str - :param display_name: Display name of the principal. - :type display_name: str - :param email: Email id of the principal. - :type email: str - :param type: Type of the principal. - :type type: str + :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 = { @@ -355,6 +432,16 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(ExpandedPropertiesPrincipal, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -365,12 +452,12 @@ def __init__( class ExpandedPropertiesRoleDefinition(msrest.serialization.Model): """Details of role definition. - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str + :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 = { @@ -387,6 +474,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -396,12 +491,12 @@ def __init__( class ExpandedPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :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 = { @@ -418,6 +513,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(ExpandedPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -427,14 +530,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :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 = { @@ -453,6 +556,16 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :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(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -463,14 +576,14 @@ def __init__( class PolicyAssignmentProperties(msrest.serialization.Model): """PolicyAssignmentProperties. - :param scope: Details of the resource scope. - :type scope: + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: + :ivar role_definition: Details of role definition. + :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :param policy: Details of the policy. - :type policy: + :ivar policy: Details of the policy. + :vartype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ @@ -483,11 +596,22 @@ class PolicyAssignmentProperties(msrest.serialization.Model): def __init__( self, *, - scope: Optional["PolicyAssignmentPropertiesScope"] = None, - role_definition: Optional["PolicyAssignmentPropertiesRoleDefinition"] = None, - policy: Optional["PolicyAssignmentPropertiesPolicy"] = None, + scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, + role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, + policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, **kwargs ): + """ + :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(PolicyAssignmentProperties, self).__init__(**kwargs) self.scope = scope self.role_definition = role_definition @@ -499,12 +623,12 @@ class PolicyAssignmentPropertiesPolicy(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Id of the policy. - :type id: str + :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 - :param last_modified_date_time: The last modified date time. - :type last_modified_date_time: ~datetime.datetime + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime """ _validation = { @@ -524,6 +648,12 @@ def __init__( last_modified_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) self.id = id self.last_modified_by = None @@ -533,12 +663,12 @@ def __init__( class PolicyAssignmentPropertiesRoleDefinition(msrest.serialization.Model): """Details of role definition. - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str + :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 = { @@ -555,6 +685,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -564,12 +702,12 @@ def __init__( class PolicyAssignmentPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :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 = { @@ -586,6 +724,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -613,6 +759,8 @@ def __init__( self, **kwargs ): + """ + """ super(PolicyProperties, self).__init__(**kwargs) self.scope = None @@ -620,12 +768,12 @@ def __init__( class PolicyPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :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 = { @@ -642,6 +790,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :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(PolicyPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -651,14 +807,14 @@ def __init__( class Principal(msrest.serialization.Model): """The name of the entity last modified it. - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str + :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 = { @@ -677,6 +833,16 @@ def __init__( email: Optional[str] = None, **kwargs ): + """ + :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(Principal, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -697,22 +863,23 @@ class RoleAssignment(msrest.serialization.Model): :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :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", "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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :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. @@ -721,8 +888,8 @@ class RoleAssignment(msrest.serialization.Model): :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -759,13 +926,34 @@ def __init__( *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = 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 ): + """ + :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", "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(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -793,22 +981,23 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): :ivar scope: The role assignment scope. :vartype scope: str - :param role_definition_id: Required. The role definition ID. - :type role_definition_id: str - :param principal_id: Required. The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar role_definition_id: Required. The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: Required. 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", "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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :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. @@ -817,8 +1006,8 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -851,13 +1040,34 @@ def __init__( *, role_definition_id: str, principal_id: str, - principal_type: Optional[Union[str, "PrincipalType"]] = 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 ): + """ + :keyword role_definition_id: Required. The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: Required. 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", "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(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id @@ -876,8 +1086,8 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str """ _attribute_map = { @@ -890,6 +1100,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id @@ -899,8 +1113,8 @@ class RoleAssignmentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] + :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 """ @@ -917,9 +1131,13 @@ class RoleAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignment"]] = None, + value: Optional[List["_models.RoleAssignment"]] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -936,52 +1154,53 @@ class RoleAssignmentSchedule(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment schedule type. :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + :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", "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. - :type role_assignment_schedule_request_id: str - :param linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated + :vartype role_assignment_schedule_request_id: str + :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. - :type linked_role_eligibility_schedule_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or + :vartype linked_role_eligibility_schedule_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: + "Activated", "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: + :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role assignment schedule. Possible values include: "Accepted", + :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", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role assignment schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role assignment schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role assignment schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :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 """ @@ -1019,21 +1238,71 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = 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, "AssignmentType"]] = None, - member_type: Optional[Union[str, "MemberType"]] = None, - status: Optional[Union[str, "Status"]] = 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["ExpandedProperties"] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs ): + """ + :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", "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", "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", "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", "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(RoleAssignmentSchedule, self).__init__(**kwargs) self.id = None self.name = None @@ -1059,12 +1328,12 @@ def __init__( class RoleAssignmentScheduleFilter(msrest.serialization.Model): """Role assignment schedule filter. - :param principal_id: Returns role assignment schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str + :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 = { @@ -1081,6 +1350,14 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1098,53 +1375,54 @@ class RoleAssignmentScheduleInstance(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment schedule instance type. :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_id: Id of the master role assignment schedule. - :type role_assignment_schedule_id: str - :param origin_role_assignment_id: Role Assignment Id in external system. - :type origin_role_assignment_id: str - :param status: The status of the role assignment schedule instance. Possible values include: + :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", "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", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role assignment schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role assignment schedule instance. - :type end_date_time: ~datetime.datetime - :param linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :type linked_role_eligibility_schedule_id: str - :param linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :type linked_role_eligibility_schedule_instance_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or + :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", "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: + :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :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 """ @@ -1183,22 +1461,73 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = 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, "Status"]] = 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, "AssignmentType"]] = None, - member_type: Optional[Union[str, "MemberType"]] = 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["ExpandedProperties"] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs ): + """ + :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", "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", "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", "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", "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(RoleAssignmentScheduleInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -1225,16 +1554,16 @@ def __init__( class RoleAssignmentScheduleInstanceFilter(msrest.serialization.Model): """Role assignment schedule instance filter. - :param principal_id: Returns role assignment schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule instances of the specific role + :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. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str - :param role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + :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. - :type role_assignment_schedule_id: str + :vartype role_assignment_schedule_id: str """ _attribute_map = { @@ -1253,6 +1582,18 @@ def __init__( role_assignment_schedule_id: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleInstanceFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1263,11 +1604,11 @@ def __init__( class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): """Role assignment schedule instance list operation result. - :param value: Role assignment schedule instance list. - :type value: + :ivar value: Role assignment schedule instance list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1278,10 +1619,17 @@ class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignmentScheduleInstance"]] = None, + value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1290,10 +1638,11 @@ def __init__( class RoleAssignmentScheduleListResult(msrest.serialization.Model): """Role assignment schedule list operation result. - :param value: Role assignment schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -1304,10 +1653,17 @@ class RoleAssignmentScheduleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignmentSchedule"]] = None, + value: Optional[List["_models.RoleAssignmentSchedule"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1326,20 +1682,20 @@ class RoleAssignmentScheduleRequest(msrest.serialization.Model): :vartype type: str :ivar scope: The role assignment schedule request scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + :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", "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role assignment schedule request. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + :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", "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", @@ -1347,30 +1703,30 @@ class RoleAssignmentScheduleRequest(msrest.serialization.Model): :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 - :param target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :type target_role_assignment_schedule_id: str - :param target_role_assignment_schedule_instance_id: The role assignment schedule instance id + :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. - :type target_role_assignment_schedule_instance_id: str - :param schedule_info: Schedule info of the role assignment schedule. - :type schedule_info: + :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 - :param linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. - :type linked_role_eligibility_schedule_id: str - :param justification: Justification for the role assignment. - :type justification: str - :param ticket_info: Ticket Info of the role assignment. - :type ticket_info: + :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 - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :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. @@ -1422,17 +1778,52 @@ def __init__( *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - request_type: Optional[Union[str, "RequestType"]] = 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["RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, + schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, linked_role_eligibility_schedule_id: Optional[str] = None, justification: Optional[str] = None, - ticket_info: Optional["RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, + ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs ): + """ + :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", "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(RoleAssignmentScheduleRequest, self).__init__(**kwargs) self.id = None self.name = None @@ -1460,14 +1851,14 @@ def __init__( class RoleAssignmentScheduleRequestFilter(msrest.serialization.Model): """Role assignment schedule request filter. - :param principal_id: Returns role assignment requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role assignment requests created by specific principal. - :type requestor_id: str - :param status: Returns role assignment requests of specific status. - :type status: str + :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 = { @@ -1486,6 +1877,16 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1496,11 +1897,11 @@ def __init__( class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): """Role assignment schedule request list operation result. - :param value: Role assignment schedule request list. - :type value: + :ivar value: Role assignment schedule request list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1511,10 +1912,17 @@ class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignmentScheduleRequest"]] = None, + value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1523,10 +1931,10 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): """Schedule info of the role assignment schedule. - :param start_date_time: Start DateTime of the role assignment schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role assignment schedule. - :type expiration: + :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 """ @@ -1539,9 +1947,16 @@ def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, + expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration @@ -1550,13 +1965,13 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): """Expiration of the role assignment schedule. - :param type: Type of the role assignment schedule expiration. Possible values include: - "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role assignment schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role assignment schedule in TimeSpan. - :type duration: str + :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", + "AfterDateTime", "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 = { @@ -1568,11 +1983,20 @@ class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.seria def __init__( self, *, - type: Optional[Union[str, "Type"]] = None, + type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role assignment schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", "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(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) self.type = type self.end_date_time = end_date_time @@ -1582,10 +2006,10 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): """Ticket Info of the role assignment. - :param ticket_number: Ticket number for the role assignment. - :type ticket_number: str - :param ticket_system: Ticket system name for the role assignment. - :type ticket_system: str + :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 = { @@ -1600,6 +2024,12 @@ def __init__( ticket_system: Optional[str] = None, **kwargs ): + """ + :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(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system @@ -1616,45 +2046,46 @@ class RoleEligibilitySchedule(msrest.serialization.Model): :vartype name: str :ivar type: The role eligibility schedule type. :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + :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", "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. - :type role_eligibility_schedule_request_id: str - :param member_type: Membership type of the role eligibility schedule. Possible values include: + :vartype role_eligibility_schedule_request_id: str + :ivar member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role eligibility schedule. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + :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", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role eligibility schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :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 """ @@ -1690,19 +2121,62 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_request_id: Optional[str] = None, - member_type: Optional[Union[str, "MemberType"]] = None, - status: Optional[Union[str, "Status"]] = 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["ExpandedProperties"] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs ): + """ + :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", "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", "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", "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(RoleEligibilitySchedule, self).__init__(**kwargs) self.id = None self.name = None @@ -1726,12 +2200,12 @@ def __init__( class RoleEligibilityScheduleFilter(msrest.serialization.Model): """Role eligibility schedule filter. - :param principal_id: Returns role eligibility schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule of the specific status. - :type status: str + :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 = { @@ -1748,6 +2222,14 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1765,42 +2247,43 @@ class RoleEligibilityScheduleInstance(msrest.serialization.Model): :vartype name: str :ivar type: The role eligibility schedule instance type. :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_id: Id of the master role eligibility schedule. - :type role_eligibility_schedule_id: str - :param status: The status of the role eligibility schedule instance. Possible values include: + :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", "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", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role eligibility schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role eligibility schedule instance. - :type end_date_time: ~datetime.datetime - :param member_type: Membership type of the role eligibility schedule. Possible values include: + :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", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :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 """ @@ -1835,18 +2318,58 @@ def __init__( scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_id: Optional[str] = None, - status: Optional[Union[str, "Status"]] = 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, "MemberType"]] = 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["ExpandedProperties"] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs ): + """ + :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", "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", "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", "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(RoleEligibilityScheduleInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -1869,16 +2392,16 @@ def __init__( class RoleEligibilityScheduleInstanceFilter(msrest.serialization.Model): """Role eligibility schedule instance filter. - :param principal_id: Returns role eligibility schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule instances of the specific role + :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. - :type role_definition_id: str - :param status: Returns role eligibility schedule instances of the specific status. - :type status: str - :param role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a + :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. - :type role_eligibility_schedule_id: str + :vartype role_eligibility_schedule_id: str """ _attribute_map = { @@ -1897,6 +2420,18 @@ def __init__( role_eligibility_schedule_id: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleInstanceFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1907,11 +2442,11 @@ def __init__( class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): """Role eligibility schedule instance list operation result. - :param value: Role eligibility schedule instance list. - :type value: + :ivar value: Role eligibility schedule instance list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1922,10 +2457,17 @@ class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleEligibilityScheduleInstance"]] = None, + value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1934,10 +2476,11 @@ def __init__( class RoleEligibilityScheduleListResult(msrest.serialization.Model): """role eligibility schedule list operation result. - :param value: role eligibility schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -1948,10 +2491,17 @@ class RoleEligibilityScheduleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleEligibilitySchedule"]] = None, + value: Optional[List["_models.RoleEligibilitySchedule"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1970,19 +2520,19 @@ class RoleEligibilityScheduleRequest(msrest.serialization.Model): :vartype type: str :ivar scope: The role eligibility schedule request scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + :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", "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role eligibility schedule request. Possible values include: + :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", "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", @@ -1991,27 +2541,27 @@ class RoleEligibilityScheduleRequest(msrest.serialization.Model): :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 - :param schedule_info: Schedule info of the role eligibility schedule. - :type schedule_info: + :ivar schedule_info: Schedule info of the role eligibility schedule. + :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :param target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. - :type target_role_eligibility_schedule_id: str - :param target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id + :vartype target_role_eligibility_schedule_id: str + :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. - :type target_role_eligibility_schedule_instance_id: str - :param justification: Justification for the role eligibility. - :type justification: str - :param ticket_info: Ticket Info of the role eligibility. - :type ticket_info: + :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 - :param condition: The conditions on the role assignment. This limits the resources it can be + :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'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :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. @@ -2062,16 +2612,48 @@ def __init__( *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, - request_type: Optional[Union[str, "RequestType"]] = None, - schedule_info: Optional["RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = 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["RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, + ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs ): + """ + :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", "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(RoleEligibilityScheduleRequest, self).__init__(**kwargs) self.id = None self.name = None @@ -2098,14 +2680,14 @@ def __init__( class RoleEligibilityScheduleRequestFilter(msrest.serialization.Model): """Role eligibility schedule request filter. - :param principal_id: Returns role eligibility requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role eligibility requests created by specific principal. - :type requestor_id: str - :param status: Returns role eligibility requests of specific status. - :type status: str + :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 = { @@ -2124,6 +2706,16 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -2134,11 +2726,11 @@ def __init__( class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): """Role eligibility schedule request list operation result. - :param value: Role eligibility schedule request list. - :type value: + :ivar value: Role eligibility schedule request list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2149,10 +2741,17 @@ class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleEligibilityScheduleRequest"]] = None, + value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2161,10 +2760,10 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): """Schedule info of the role eligibility schedule. - :param start_date_time: Start DateTime of the role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role eligibility schedule. - :type expiration: + :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 """ @@ -2177,9 +2776,16 @@ def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, + expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration @@ -2188,13 +2794,13 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): """Expiration of the role eligibility schedule. - :param type: Type of the role eligibility schedule expiration. Possible values include: + :ivar type: Type of the role eligibility schedule expiration. Known values are: "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role eligibility schedule in TimeSpan. - :type duration: str + :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 = { @@ -2206,11 +2812,20 @@ class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.seri def __init__( self, *, - type: Optional[Union[str, "Type"]] = None, + type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role eligibility schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", "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(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) self.type = type self.end_date_time = end_date_time @@ -2220,10 +2835,10 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): """Ticket Info of the role eligibility. - :param ticket_number: Ticket number for the role eligibility. - :type ticket_number: str - :param ticket_system: Ticket system name for the role eligibility. - :type ticket_system: str + :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 = { @@ -2238,6 +2853,12 @@ def __init__( ticket_system: Optional[str] = None, **kwargs ): + """ + :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(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system @@ -2254,20 +2875,20 @@ class RoleManagementPolicy(msrest.serialization.Model): :vartype name: str :ivar type: The role management policy type. :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param display_name: The role management policy display name. - :type display_name: str - :param description: The role management policy description. - :type description: str - :param is_organization_default: The role management policy is default policy. - :type is_organization_default: bool + :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 - :param rules: The rule applied to the policy. - :type rules: + :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: @@ -2309,9 +2930,22 @@ def __init__( display_name: Optional[str] = None, description: Optional[str] = None, is_organization_default: Optional[bool] = None, - rules: Optional[List["RoleManagementPolicyRule"]] = None, + rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, **kwargs ): + """ + :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(RoleManagementPolicy, self).__init__(**kwargs) self.id = None self.name = None @@ -2335,16 +2969,16 @@ class RoleManagementPolicyRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ @@ -2366,9 +3000,16 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs ): + """ + :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(RoleManagementPolicyRule, self).__init__(**kwargs) self.id = id self.rule_type = None # type: Optional[str] @@ -2380,19 +3021,19 @@ class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param setting: The approval setting. - :type setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings + :ivar setting: The approval setting. + :vartype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ _validation = { @@ -2410,10 +3051,19 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, - setting: Optional["ApprovalSettings"] = None, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + setting: Optional["_models.ApprovalSettings"] = None, **kwargs ): + """ + :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(RoleManagementPolicyApprovalRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str self.setting = setting @@ -2430,12 +3080,12 @@ class RoleManagementPolicyAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role management policy type. :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param role_definition_id: The role definition of management policy assignment. - :type role_definition_id: str - :param policy_id: The policy id role management policy assignment. - :type policy_id: 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 @@ -2466,6 +3116,14 @@ def __init__( policy_id: Optional[str] = None, **kwargs ): + """ + :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(RoleManagementPolicyAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -2479,11 +3137,11 @@ def __init__( class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): """Role management policy assignment list operation result. - :param value: Role management policy assignment list. - :type value: + :ivar value: Role management policy assignment list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2494,10 +3152,17 @@ class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleManagementPolicyAssignment"]] = None, + value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleManagementPolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2508,21 +3173,21 @@ class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_enabled: The value indicating if rule is enabled. - :type is_enabled: bool - :param claim_value: The claim value. - :type claim_value: str + :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 = { @@ -2541,11 +3206,22 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs ): + """ + :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(RoleManagementPolicyAuthenticationContextRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str self.is_enabled = is_enabled @@ -2557,19 +3233,19 @@ class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param enabled_rules: The list of enabled rules. - :type enabled_rules: list[str or + :ivar enabled_rules: The list of enabled rules. + :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ @@ -2588,10 +3264,20 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, - enabled_rules: Optional[List[Union[str, "EnablementRules"]]] = None, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs ): + """ + :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(RoleManagementPolicyEnablementRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str self.enabled_rules = enabled_rules @@ -2602,21 +3288,21 @@ class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_expiration_required: The value indicating whether expiration is required. - :type is_expiration_required: bool - :param maximum_duration: The maximum duration of expiration in timespan. - :type maximum_duration: str + :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 = { @@ -2635,11 +3321,22 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs ): + """ + :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(RoleManagementPolicyExpirationRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str self.is_expiration_required = is_expiration_required @@ -2649,10 +3346,10 @@ def __init__( class RoleManagementPolicyListResult(msrest.serialization.Model): """Role management policy list operation result. - :param value: Role management policy list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -2663,10 +3360,17 @@ class RoleManagementPolicyListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleManagementPolicy"]] = None, + value: Optional[List["_models.RoleManagementPolicy"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(RoleManagementPolicyListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2677,32 +3381,31 @@ class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param notification_type: The type of notification. Possible values include: "Email". - :type notification_type: str or + :ivar notification_type: The type of notification. Known values are: "Email". + :vartype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :param notification_level: The notification level. Possible values include: "None", "Critical", - "All". - :type notification_level: str or + :ivar notification_level: The notification level. Known values are: "None", "Critical", "All". + :vartype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :param recipient_type: The recipient type. Possible values include: "Requestor", "Approver", - "Admin". - :type recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :param notification_recipients: The list notification recipients. - :type notification_recipients: list[str] - :param is_default_recipients_enabled: Its value determine if the notification need to be sent - to the recipient type specified in policy rule. - :type is_default_recipients_enabled: bool + :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", "Admin". + :vartype recipient_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType + :ivar notification_recipients: The list notification recipients. + :vartype notification_recipients: list[str] + :ivar is_default_recipients_enabled: Its value determine if the notification need to be sent to + the recipient type specified in policy rule. + :vartype is_default_recipients_enabled: bool """ _validation = { @@ -2724,14 +3427,37 @@ def __init__( self, *, id: Optional[str] = None, - target: Optional["RoleManagementPolicyRuleTarget"] = None, - notification_type: Optional[Union[str, "NotificationDeliveryMechanism"]] = None, - notification_level: Optional[Union[str, "NotificationLevel"]] = None, - recipient_type: Optional[Union[str, "RecipientType"]] = None, + 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 ): + """ + :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. Known values are: "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", + "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", + "Admin". + :paramtype recipient_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType + :keyword notification_recipients: The list notification recipients. + :paramtype notification_recipients: list[str] + :keyword is_default_recipients_enabled: Its value determine if the notification need to be sent + to the recipient type specified in policy rule. + :paramtype is_default_recipients_enabled: bool + """ super(RoleManagementPolicyNotificationRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str self.notification_type = notification_type @@ -2744,18 +3470,18 @@ def __init__( class RoleManagementPolicyRuleTarget(msrest.serialization.Model): """The role management policy rule target. - :param caller: The caller of the setting. - :type caller: str - :param operations: The type of operation. - :type operations: list[str] - :param level: The assignment level to which it is applied. - :type level: str - :param target_objects: The list of target objects. - :type target_objects: list[str] - :param inheritable_settings: The list of inheritable settings. - :type inheritable_settings: list[str] - :param enforced_settings: The list of enforced settings. - :type enforced_settings: list[str] + :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 it 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 = { @@ -2778,6 +3504,20 @@ def __init__( enforced_settings: Optional[List[str]] = None, **kwargs ): + """ + :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 it 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(RoleManagementPolicyRuleTarget, self).__init__(**kwargs) self.caller = caller self.operations = operations @@ -2790,14 +3530,14 @@ def __init__( class UserSet(msrest.serialization.Model): """The detail of a user. - :param user_type: The type of user. Possible values include: "User", "Group". - :type user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :param is_backup: The value indicating whether the user is a backup fallback approver. - :type is_backup: bool - :param id: The object id of the user. - :type id: str - :param description: The description of the user. - :type description: str + :ivar user_type: The type of user. Known values are: "User", "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 = { @@ -2810,12 +3550,22 @@ class UserSet(msrest.serialization.Model): def __init__( self, *, - user_type: Optional[Union[str, "UserType"]] = None, + user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword user_type: The type of user. Known values are: "User", "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(UserSet, self).__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup @@ -2830,8 +3580,8 @@ class ValidationResponse(msrest.serialization.Model): :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool - :param error_info: Failed validation result details. - :type error_info: + :ivar error_info: Failed validation result details. + :vartype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ @@ -2847,9 +3597,14 @@ class ValidationResponse(msrest.serialization.Model): def __init__( self, *, - error_info: Optional["ValidationResponseErrorInfo"] = None, + error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs ): + """ + :keyword error_info: Failed validation result details. + :paramtype error_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo + """ super(ValidationResponse, self).__init__(**kwargs) self.is_valid = None self.error_info = error_info @@ -2880,6 +3635,8 @@ def __init__( self, **kwargs ): + """ + """ super(ValidationResponseErrorInfo, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 97e8639830c2..a8e937e9bdb8 100644 --- 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 @@ -17,6 +17,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'RoleAssignmentsOperations', 'EligibleChildResourcesOperations', @@ -29,3 +32,5 @@ 'RoleManagementPoliciesOperations', 'RoleManagementPolicyAssignmentsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 5249728dc289..cce39b238647 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,90 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class EligibleChildResourcesOperations(object): - """EligibleChildResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EligibleChildResourcesListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.EligibleChildResourcesListResult]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. @@ -59,48 +97,56 @@ def get( :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'. + 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 EligibleChildResourcesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EligibleChildResourcesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,7 +155,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,7 +168,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/eligibleChildResources'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index fc497e655b9e..65aeb907dd3f 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class RoleAssignmentScheduleInstancesOperations(object): - """RoleAssignmentScheduleInstancesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RoleAssignmentScheduleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleInstanceListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleInstanceListResult]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. @@ -61,48 +134,56 @@ def list_for_scope( 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. + 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 RoleAssignmentScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,7 +192,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,18 +205,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleInstance" + 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. @@ -144,32 +230,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleInstanceName': self._serialize.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,4 +270,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + 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 index bc66ad220fe9..b626d7a02a4b 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,204 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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, + *, + json: Optional[_models.RoleAssignmentScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentScheduleRequestsOperations(object): - """RoleAssignmentScheduleRequestsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def create( self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - parameters, # type: "_models.RoleAssignmentScheduleRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleRequest" + scope: str, + role_assignment_schedule_request_name: str, + parameters: _models.RoleAssignmentScheduleRequest, + **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 @@ -63,47 +214,49 @@ def create( '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment to create. It can - be any valid GUID. + :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. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -116,15 +269,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleRequest" + 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. @@ -137,32 +292,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequest] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +332,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleRequestListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleRequestListResult]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. @@ -194,48 +353,56 @@ def list_for_scope( 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. + 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 RoleAssignmentScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleRequestListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -244,7 +411,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,18 +424,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore - def cancel( + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -277,32 +449,34 @@ def cancel( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,4 +486,5 @@ def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + 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 index 459616f2e5c0..6aaa821c09c4 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class RoleAssignmentSchedulesOperations(object): - """RoleAssignmentSchedulesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RoleAssignmentSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentSchedule" + 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. @@ -63,32 +136,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleName': self._serialize.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentSchedule] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,15 +176,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentScheduleListResult]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. @@ -119,47 +196,56 @@ def list_for_scope( 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 RoleAssignmentScheduleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,7 +254,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +267,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore 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 index 08463b4693be..ab49f07ae712 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,601 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + resource_group_name: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class RoleAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentsOperations(object): - """RoleAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_subscription( self, - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,82 +609,96 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """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. :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,32 +707,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + 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.RoleAssignmentListResult]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -233,56 +751,68 @@ def list_for_resource( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -291,29 +821,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + 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: @@ -323,46 +858,47 @@ def get( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -371,16 +907,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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: @@ -391,48 +929,50 @@ def create( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -445,16 +985,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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: @@ -464,46 +1006,47 @@ def delete( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -514,16 +1057,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def validate( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidationResponse" + scope: str, + role_assignment_name: str, + parameters: _models.RoleAssignmentCreateParameters, + **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: @@ -534,48 +1079,50 @@ def validate( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ValidationResponse] + + _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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -584,16 +1131,18 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate'} # type: ignore + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentListResult]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -603,52 +1152,60 @@ def list_for_scope( :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. + 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. + :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 RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -657,28 +1214,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def get_by_id( self, - role_assignment_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + 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, @@ -686,45 +1248,46 @@ def get_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -733,15 +1296,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **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, @@ -750,47 +1315,49 @@ def create_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignment] + + _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, + template_url=self.create_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -803,15 +1370,17 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_assignment_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + 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, @@ -819,45 +1388,46 @@ def delete_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :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 or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RoleAssignment"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RoleAssignment]] + + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -868,15 +1438,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def validate_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidationResponse" + role_assignment_id: str, + parameters: _models.RoleAssignmentCreateParameters, + **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, @@ -885,47 +1457,49 @@ def validate_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ValidationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ValidationResponse] + + _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, + template_url=self.validate_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -934,4 +1508,6 @@ def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - validate_by_id.metadata = {'url': '/{roleAssignmentId}/validate'} # type: ignore + + validate_by_id.metadata = {'url': "/{roleAssignmentId}/validate"} # type: ignore + 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 index 0d44db0bf21b..b33594f13fa3 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class RoleEligibilityScheduleInstancesOperations(object): - """RoleEligibilityScheduleInstancesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RoleEligibilityScheduleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleInstanceListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleInstanceListResult]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. @@ -61,47 +134,56 @@ def list_for_scope( 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 RoleEligibilityScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +192,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,18 +205,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleInstance" + 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. @@ -143,32 +230,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleInstanceName': self._serialize.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,4 +270,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + 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 index ea97a5f68681..e27760f0f1dc 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,204 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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, + *, + json: Optional[_models.RoleEligibilityScheduleRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleEligibilityScheduleRequestsOperations(object): - """RoleEligibilityScheduleRequestsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def create( self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - parameters, # type: "_models.RoleEligibilityScheduleRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleRequest" + scope: str, + role_eligibility_schedule_request_name: str, + parameters: _models.RoleEligibilityScheduleRequest, + **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 @@ -67,43 +218,45 @@ def create( can be any valid GUID. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -116,15 +269,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleRequest" + 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. @@ -137,32 +292,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequest] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +332,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleRequestListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleRequestListResult]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. @@ -194,48 +353,56 @@ def list_for_scope( 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. + 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 RoleEligibilityScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleRequestListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -244,7 +411,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,18 +424,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore - def cancel( + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -277,32 +449,34 @@ def cancel( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,4 +486,5 @@ def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + 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 index a3d1b5ff8321..5a003927350c 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class RoleEligibilitySchedulesOperations(object): - """RoleEligibilitySchedulesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RoleEligibilitySchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilitySchedule" + 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. @@ -63,32 +136,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilitySchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleName': self._serialize.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilitySchedule] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,15 +176,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleEligibilityScheduleListResult]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. @@ -119,47 +196,56 @@ def list_for_scope( 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 RoleEligibilityScheduleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleEligibilityScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,7 +254,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +267,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore 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 index bbf34302c894..47c2abd6f768 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,199 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleManagementPolicy] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleManagementPoliciesOperations(object): - """RoleManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - scope, # type: str - role_management_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicy" + 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. @@ -63,32 +210,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,16 +250,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace def update( self, - scope, # type: str - role_management_policy_name, # type: str - parameters, # type: "_models.RoleManagementPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicy" + scope: str, + role_management_policy_name: str, + parameters: _models.RoleManagementPolicy, + **kwargs: Any + ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. @@ -124,37 +275,38 @@ def update( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicy] + + _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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -167,15 +319,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore - def delete( + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_management_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -187,32 +341,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -222,56 +378,65 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + @distributed_trace def list_for_scope( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleManagementPolicyListResult"] + scope: str, + **kwargs: Any + ) -> Iterable[_models.RoleManagementPolicyListResult]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. :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 RoleManagementPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,7 +445,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -289,7 +458,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore 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 index fea0ec5db6e3..b28e71e10141 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,199 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleManagementPolicyAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleManagementPolicyAssignmentsOperations(object): - """RoleManagementPolicyAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2020_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - scope, # type: str - role_management_policy_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicyAssignment" + 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. @@ -64,32 +211,34 @@ def get( :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,16 +251,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_management_policy_assignment_name, # type: str - parameters, # type: "_models.RoleManagementPolicyAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicyAssignment" + scope: str, + role_management_policy_assignment_name: str, + parameters: _models.RoleManagementPolicyAssignment, + **kwargs: Any + ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. @@ -120,43 +271,45 @@ def create( management policy assignment to upsert. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignment] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -169,15 +322,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore - def delete( + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_management_policy_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -190,32 +345,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,56 +382,65 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + @distributed_trace def list_for_scope( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleManagementPolicyAssignmentListResult"] + scope: str, + **kwargs: Any + ) -> Iterable[_models.RoleManagementPolicyAssignmentListResult]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. :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 RoleManagementPolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleManagementPolicyAssignmentListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -283,7 +449,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -292,7 +462,8 @@ 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'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 9ef3cafd5e61..dd111748cf54 100644 --- 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 @@ -6,97 +6,117 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import RoleAssignmentApprovalOperations -from .operations import RoleAssignmentApprovalStepsOperations -from .operations import RoleAssignmentApprovalStepOperations -from .operations import ScopeRoleAssignmentApprovalOperations -from .operations import ScopeRoleAssignmentApprovalStepsOperations -from .operations import ScopeRoleAssignmentApprovalStepOperations from . import models +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(object): - """Request Approvals service provides the workflow for running request approvals on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :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, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 95df76e19b26..e70a52bca679 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,20 +27,24 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :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, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-01-01-preview" + 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) @@ -62,4 +64,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2021_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json index 143a0ba7ab5f..c3054bf380f0 100644 --- 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 @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Request Approvals service provides the workflow for running request approvals on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index 4d7b16fdf35a..31caee5db33c 100644 --- 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 @@ -6,93 +6,117 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import RoleAssignmentApprovalOperations -from .operations import RoleAssignmentApprovalStepsOperations -from .operations import RoleAssignmentApprovalStepOperations -from .operations import ScopeRoleAssignmentApprovalOperations -from .operations import ScopeRoleAssignmentApprovalStepsOperations -from .operations import ScopeRoleAssignmentApprovalStepOperations from .. import models +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(object): - """Request Approvals service provides the workflow for running request approvals on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index bb368f50e812..b39becd2588e 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :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__( @@ -34,12 +37,14 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-01-01-preview" + 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) @@ -58,4 +63,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2021_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index c5030cb2549c..c4171c2f719b 100644 --- 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 @@ -14,6 +14,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'RoleAssignmentApprovalOperations', @@ -23,3 +26,5 @@ 'ScopeRoleAssignmentApprovalStepsOperations', 'ScopeRoleAssignmentApprovalStepOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 86197f34d0c0..5f572e98abc8 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,93 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +101,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 0e6672403f1e..8f3ba6ff38d6 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentApprovalListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentApprovalListResult]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: @@ -55,44 +59,54 @@ def list( $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. + 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 RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,26 +115,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace_async async def get_by_id( self, approval_id: str, **kwargs: Any - ) -> "_models.RoleAssignmentApproval": + ) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -130,36 +150,38 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApproval"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApproval] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -168,4 +190,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + 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 index 041f280a3e39..0d5610471e95 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,49 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentApprovalStepOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get_by_id( self, approval_id: str, stage_id: str, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -57,37 +60,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -96,15 +101,18 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, - properties: "_models.RoleAssignmentApprovalStepProperties", + properties: _models.RoleAssignmentApprovalStepProperties, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -112,48 +120,50 @@ async def patch( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -162,15 +172,18 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def put( self, approval_id: str, stage_id: str, - properties: "_models.RoleAssignmentApprovalStepProperties", + properties: _models.RoleAssignmentApprovalStepProperties, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -178,48 +191,50 @@ async def put( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -228,4 +243,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + 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 index 746cf0564221..7d075fb2e227 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,90 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """RoleAssignmentApprovalStepsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def list( self, approval_id: str, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStepListResult": + ) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. :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 + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStepListResult] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -92,4 +98,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + 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 index ac2f82cdfe79..59e46d399194 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ScopeRoleAssignmentApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentApprovalListResult"]: + ) -> AsyncIterable[_models.RoleAssignmentApprovalListResult]: """Get role assignment approvals. :param scope: The scope of the resource. @@ -58,48 +62,56 @@ def list( $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. + 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 RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,27 +120,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace_async async def get_by_id( self, approval_id: str, scope: str, **kwargs: Any - ) -> "_models.RoleAssignmentApproval": + ) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -140,37 +158,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApproval"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApproval] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -179,4 +199,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + 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 index e5134c9426a1..70185991f5ed 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ScopeRoleAssignmentApprovalStepOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get_by_id( self, approval_id: str, stage_id: str, scope: str, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -60,38 +63,40 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -100,16 +105,19 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, scope: str, - properties: "_models.RoleAssignmentApprovalStepProperties", + properties: _models.RoleAssignmentApprovalStepProperties, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -119,49 +127,51 @@ async def patch( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -170,16 +180,19 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def put( self, approval_id: str, stage_id: str, scope: str, - properties: "_models.RoleAssignmentApprovalStepProperties", + properties: _models.RoleAssignmentApprovalStepProperties, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStep": + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -189,49 +202,51 @@ async def put( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -240,4 +255,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + 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 index d6b9c1f103b2..13497fa6c011 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,49 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """ScopeRoleAssignmentApprovalStepsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def list( self, approval_id: str, scope: str, **kwargs: Any - ) -> "_models.RoleAssignmentApprovalStepListResult": + ) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -54,40 +57,43 @@ async def list( :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 + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStepListResult] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -96,4 +102,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + 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 index 6bfcb58bfb9a..865776a01e06 100644 --- 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 @@ -6,35 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RoleAssignmentApproval # type: ignore - from ._models import RoleAssignmentApprovalListResult # type: ignore - from ._models import RoleAssignmentApprovalStep # type: ignore - from ._models import RoleAssignmentApprovalStepListResult # type: ignore - from ._models import RoleAssignmentApprovalStepProperties # type: ignore +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, RoleAssignmentApprovalStepReviewResult, RoleAssignmentApprovalStepStatus, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ErrorDefinition', 'ErrorDefinitionProperties', @@ -50,3 +41,5 @@ 'RoleAssignmentApprovalStepReviewResult', 'RoleAssignmentApprovalStepStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index c02590626aa8..ce70f006c7de 100644 --- 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 @@ -6,34 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class RoleAssignmentApprovalActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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 """ @@ -42,7 +26,7 @@ class RoleAssignmentApprovalStepReviewResult(with_metaclass(_CaseInsensitiveEnum DENY = "Deny" NOT_REVIEWED = "NotReviewed" -class RoleAssignmentApprovalStepStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalStepStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This read-only field specifies the status of an approval. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py deleted file mode 100644 index 88eb0cd0d103..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py +++ /dev/null @@ -1,416 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.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 - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :param origin: Origin of the operation. Values include user|system|user,system. - :type 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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentApproval(msrest.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 - :param stages: This is the collection of stages returned when one does an expand on it. - :type 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, - **kwargs - ): - super(RoleAssignmentApproval, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.stages = kwargs.get('stages', None) - - -class RoleAssignmentApprovalListResult(msrest.serialization.Model): - """List of role assignment approvals. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role Assignment Approval list. - :type 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, - **kwargs - ): - super(RoleAssignmentApprovalListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentApprovalStep(msrest.serialization.Model): - """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 - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "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 - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "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, - **kwargs - ): - super(RoleAssignmentApprovalStep, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = kwargs.get('review_result', None) - self.justification = kwargs.get('justification', None) - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class RoleAssignmentApprovalStepListResult(msrest.serialization.Model): - """List of role assignment approval stage list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role Assignment Approval Step list. - :type 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, - **kwargs - ): - super(RoleAssignmentApprovalStepListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "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 - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "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, - **kwargs - ): - super(RoleAssignmentApprovalStepProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = kwargs.get('review_result', None) - self.justification = kwargs.get('justification', None) - 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/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py index f33ff8c7edcc..17cc30832b9a 100644 --- 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 @@ -6,19 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -28,9 +30,14 @@ class ErrorDefinition(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDefinitionProperties"] = None, + error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -42,8 +49,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -61,6 +68,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -69,14 +80,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :param origin: Origin of the operation. Values include user|system|user,system. - :type origin: str + :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 = { @@ -91,10 +102,20 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs ): + """ + :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(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -135,6 +156,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -145,10 +168,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :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 = { @@ -159,10 +182,16 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -179,8 +208,8 @@ class RoleAssignmentApproval(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param stages: This is the collection of stages returned when one does an expand on it. - :type stages: + :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] """ @@ -200,9 +229,14 @@ class RoleAssignmentApproval(msrest.serialization.Model): def __init__( self, *, - stages: Optional[List["RoleAssignmentApprovalStep"]] = None, + stages: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs ): + """ + :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(RoleAssignmentApproval, self).__init__(**kwargs) self.id = None self.name = None @@ -215,8 +249,9 @@ class RoleAssignmentApprovalListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role Assignment Approval list. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] + :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 """ @@ -233,9 +268,14 @@ class RoleAssignmentApprovalListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignmentApproval"]] = None, + value: Optional[List["_models.RoleAssignmentApproval"]] = None, **kwargs ): + """ + :keyword value: Role Assignment Approval list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] + """ super(RoleAssignmentApprovalListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -252,28 +292,28 @@ class RoleAssignmentApprovalStep(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "Escalated". + :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", + "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 - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or + :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", + "NotReviewed". + :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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. Possible values include: - "user", "servicePrincipal". + :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user", + "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. @@ -315,10 +355,21 @@ def __init__( self, *, display_name: Optional[str] = None, - review_result: Optional[Union[str, "RoleAssignmentApprovalStepReviewResult"]] = None, + review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", + "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(RoleAssignmentApprovalStep, self).__init__(**kwargs) self.id = None self.name = None @@ -340,8 +391,8 @@ class RoleAssignmentApprovalStepListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role Assignment Approval Step list. - :type value: + :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 @@ -359,9 +410,14 @@ class RoleAssignmentApprovalStepListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RoleAssignmentApprovalStep"]] = None, + value: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs ): + """ + :keyword value: Role Assignment Approval Step list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] + """ super(RoleAssignmentApprovalStepListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -372,28 +428,28 @@ class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "Escalated". + :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", + "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 - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or + :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", + "NotReviewed". + :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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. Possible values include: - "user", "servicePrincipal". + :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user", + "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. @@ -429,10 +485,21 @@ def __init__( self, *, display_name: Optional[str] = None, - review_result: Optional[Union[str, "RoleAssignmentApprovalStepReviewResult"]] = None, + review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", + "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(RoleAssignmentApprovalStepProperties, self).__init__(**kwargs) self.display_name = display_name self.status = 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index c5030cb2549c..c4171c2f719b 100644 --- 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 @@ -14,6 +14,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'RoleAssignmentApprovalOperations', @@ -23,3 +26,5 @@ 'ScopeRoleAssignmentApprovalStepsOperations', 'ScopeRoleAssignmentApprovalStepOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 7e220da70af2..7676e8724eb8 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,123 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +131,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 3aba6671037f..740aed86e5c4 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,116 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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') -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class RoleAssignmentApprovalOperations(object): - """RoleAssignmentApprovalOperations operations. +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 {}) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentApprovalListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentApprovalListResult]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: @@ -60,44 +125,54 @@ def list( $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. + 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 RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +181,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace def get_by_id( self, - approval_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApproval" + approval_id: str, + **kwargs: Any + ) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -136,36 +216,38 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApproval"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApproval] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -174,4 +256,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + 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 index f7b151bea740..e8a447f2e808 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,173 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentApprovalStepProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + *, + json: Optional[_models.RoleAssignmentApprovalStepProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class RoleAssignmentApprovalStepOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentApprovalStepOperations(object): - """RoleAssignmentApprovalStepOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get_by_id( self, - approval_id, # type: str - stage_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -62,37 +184,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -101,16 +225,18 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def patch( self, - approval_id, # type: str - stage_id, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + properties: _models.RoleAssignmentApprovalStepProperties, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -118,48 +244,50 @@ def patch( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -168,16 +296,18 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def put( self, - approval_id, # type: str - stage_id, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + properties: _models.RoleAssignmentApprovalStepProperties, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -185,48 +315,50 @@ def put( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -235,4 +367,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + 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 index 9f1af04b4e06..24eb9a96d436 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,126 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RoleAssignmentApprovalStepsOperations(object): - """RoleAssignmentApprovalStepsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - approval_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStepListResult" + approval_id: str, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. :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 + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStepListResult] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -97,4 +134,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + 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 index 9a21685006fc..b3798e82e175 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class ScopeRoleAssignmentApprovalOperations(object): - """ScopeRoleAssignmentApprovalOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScopeRoleAssignmentApprovalOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentApprovalListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.RoleAssignmentApprovalListResult]: """Get role assignment approvals. :param scope: The scope of the resource. @@ -63,48 +136,56 @@ def list( $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. + 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 RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,28 +194,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace def get_by_id( self, - approval_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApproval" + approval_id: str, + scope: str, + **kwargs: Any + ) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -146,37 +232,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApproval"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApproval] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -185,4 +273,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + 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 index e883fa439610..7ada52475ba9 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,180 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.RoleAssignmentApprovalStepProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + scope: str, + *, + json: Optional[_models.RoleAssignmentApprovalStepProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class ScopeRoleAssignmentApprovalStepOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ScopeRoleAssignmentApprovalStepOperations(object): - """ScopeRoleAssignmentApprovalStepOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get_by_id( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + 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. @@ -65,38 +193,40 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -105,17 +235,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def patch( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + scope: str, + properties: _models.RoleAssignmentApprovalStepProperties, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -125,49 +257,51 @@ def patch( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -176,17 +310,19 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def put( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + scope: str, + properties: _models.RoleAssignmentApprovalStepProperties, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. @@ -196,49 +332,51 @@ def put( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStep"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStep] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -247,4 +385,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + 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 index 5a02802fe664..c9fa89ed8aa4 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,87 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ScopeRoleAssignmentApprovalStepsOperations(object): - """ScopeRoleAssignmentApprovalStepsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - approval_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStepListResult" + approval_id: str, + scope: str, + **kwargs: Any + ) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -59,40 +95,43 @@ def list( :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 + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleAssignmentApprovalStepListResult] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -101,4 +140,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + 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 index ae11ad3e4d97..d9033c6b26a4 100644 --- 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 @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AuthorizationManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _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 index 024c0891cf62..0bf1a7721848 100644 --- 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 @@ -6,113 +6,133 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from . import models +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(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + 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(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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): # type: () -> None 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 index 06e446c95642..f00daf9b6e81 100644 --- 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 @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + 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.api_version = "2021-03-01-preview" + 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) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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/v2021_03_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json index b908ed305c6e..f6f32b346629 100644 --- 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 @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 index 48944bf3938a..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" 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 index ffc49d028e42..069a548e077c 100644 --- 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._authorization_management_client import AuthorizationManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # 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 index 3d185b7b8558..c955e1a65076 100644 --- 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 @@ -6,109 +6,133 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from .. import models +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(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=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 + :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 + :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 + :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 + :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 + :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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._client, self._config, self._serialize, self._deserialize + ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() 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 index 984ddf81ab63..5d093e186e98 100644 --- 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + 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.api_version = "2021-03-01-preview" + 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) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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/v2021_03_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 9fe7178064d5..b430fe8f3b8e 100644 --- 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 @@ -16,6 +16,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'AccessReviewScheduleDefinitionsOperations', @@ -27,3 +30,5 @@ 'AccessReviewInstancesAssignedForMyApprovalOperations', 'AccessReviewInstanceMyDecisionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 07a4a1853c02..b2be7eadfc8c 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewDefaultSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace_async async def get( self, **kwargs: Any - ) -> "_models.AccessReviewDefaultSettings": + ) -> _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 @@ -51,36 +54,38 @@ async def get( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -89,57 +94,62 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async async def put( self, - properties: "_models.AccessReviewScheduleSettings", + properties: _models.AccessReviewScheduleSettings, **kwargs: Any - ) -> "_models.AccessReviewDefaultSettings": + ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -148,4 +158,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + 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 index 46aa06675b42..01a29932fc25 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceDecisionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -57,50 +60,60 @@ def list( :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. + 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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +122,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index 11b4e5669c57..05a58de5cf59 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/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceMyDecisionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :attr:`access_review_instance_my_decisions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -57,49 +61,58 @@ def list( :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. + 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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,28 +121,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> "_models.AccessReviewDecision": + ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -143,38 +162,40 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -183,16 +204,19 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, - properties: "_models.AccessReviewDecisionProperties", + properties: _models.AccessReviewDecisionProperties, **kwargs: Any - ) -> "_models.AccessReviewDecision": + ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -202,49 +226,51 @@ async def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -253,4 +279,6 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # 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/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py index 05b717381d86..9dc87436fca5 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/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,44 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstanceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :attr:`access_review_instance` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - async def stop( + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -57,46 +60,50 @@ async def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - async def reset_decisions( + @distributed_trace_async + async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -113,46 +120,50 @@ async def reset_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - async def apply_decisions( + @distributed_trace_async + async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -169,46 +180,50 @@ async def apply_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore - async def send_reminders( + + @distributed_trace_async + async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -225,46 +240,50 @@ async def send_reminders( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + - async def accept_recommendations( + @distributed_trace_async + async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -281,40 +300,43 @@ async def accept_recommendations( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + 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 index 51d114152204..b611177da491 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstancesAssignedForMyApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -54,48 +58,56 @@ def list( :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. + 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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,27 +116,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> "_models.AccessReviewInstance": + ) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -136,37 +154,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -175,4 +195,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index ac8213f00104..2f9475dc7224 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewInstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -54,49 +58,58 @@ def list( :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. + 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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,27 +118,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> "_models.AccessReviewInstance": + ) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -137,38 +156,40 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -177,4 +198,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index af0a064b834a..9a72deb8a04e 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,102 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: """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. + 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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +110,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore 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/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index d762fddac400..21b3f716e458 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/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,105 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """AccessReviewScheduleDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :attr:`access_review_schedule_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: """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. + 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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,26 +113,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, **kwargs: Any - ) -> "_models.AccessReviewScheduleDefinition": + ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -130,37 +148,39 @@ async def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -169,9 +189,12 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -185,97 +208,103 @@ async def delete_by_id( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, - properties: "_models.AccessReviewScheduleDefinitionProperties", + properties: _models.AccessReviewScheduleDefinitionProperties, **kwargs: Any - ) -> "_models.AccessReviewScheduleDefinition": + ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -284,9 +313,12 @@ async def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -300,40 +332,43 @@ async def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # 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/v2021_03_01_preview/aio/operations/_operations.py index 7dafd9b6b2b7..7a354e0fa180 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/v2021_03_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,93 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +101,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 61394ed229f2..87ced05d1886 100644 --- 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 @@ -6,48 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import AccessReviewDecision # type: ignore - from ._models import AccessReviewDecisionIdentity # type: ignore - from ._models import AccessReviewDecisionListResult # type: ignore - from ._models import AccessReviewDecisionProperties # type: ignore - from ._models import AccessReviewDecisionResource # type: ignore - from ._models import AccessReviewDecisionServicePrincipalIdentity # type: ignore - from ._models import AccessReviewDecisionUserIdentity # type: ignore - from ._models import AccessReviewDefaultSettings # type: ignore - from ._models import AccessReviewInstance # type: ignore - from ._models import AccessReviewInstanceListResult # type: ignore - from ._models import AccessReviewReviewer # type: ignore - from ._models import AccessReviewScheduleDefinition # type: ignore - from ._models import AccessReviewScheduleDefinitionListResult # type: ignore - from ._models import AccessReviewScheduleDefinitionProperties # type: ignore - from ._models import AccessReviewScheduleSettings # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore +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, @@ -66,7 +45,9 @@ DecisionTargetType, DefaultDecisionType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AccessReviewDecision', 'AccessReviewDecisionIdentity', @@ -104,3 +85,5 @@ 'DecisionTargetType', 'DefaultDecisionType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 3342334011d4..c001228057aa 100644 --- 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 @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +18,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The outcome of applying the decision. """ @@ -52,7 +36,7 @@ class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" APPLY_NOT_SUPPORTED = "ApplyNotSupported" -class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +52,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +67,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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 """ @@ -94,14 +78,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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. @@ -111,7 +95,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This read-only field specifies the status of an accessReview. """ @@ -127,14 +111,14 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopeAssignmentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopeAssignmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The role assignment state eligible/active to review """ ELIGIBLE = "eligible" ACTIVE = "active" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type user/servicePrincipal to review """ @@ -142,20 +126,20 @@ class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, st GUEST_USER = "guestUser" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of resource """ AZURE_ROLE = "azureRole" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This specifies the behavior for the autoReview feature when an access review completes. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py deleted file mode 100644 index ae4866e63512..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py +++ /dev/null @@ -1,1352 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessReviewDecision(msrest.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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type 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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "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. Possible values include: "user", "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. Possible values include: "user", "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 - :param type_properties_resource_type: The type of resource.Constant filled by server. Possible - values include: "azureRole". - :type 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 - :param type_properties_principal_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type 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, - **kwargs - ): - super(AccessReviewDecision, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - 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 = None # type: Optional[str] - self.id_properties_resource_id = None - self.display_name_properties_resource_display_name = None - self.type_properties_principal_type = None # type: Optional[str] - self.id_properties_principal_id = None - self.display_name_properties_principal_display_name = None - - -class AccessReviewDecisionIdentity(msrest.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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(AccessReviewDecisionIdentity, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.id = None - self.display_name = None - - -class AccessReviewDecisionListResult(msrest.serialization.Model): - """List of access review decisions. - - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewDecision]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewDecisionProperties(msrest.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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type 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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "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. - Possible values include: "user", "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. - Possible values include: "user", "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 - :param type_resource_type: The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type 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 - :param type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled - by server. Possible values include: "user", "servicePrincipal". - :type 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, - **kwargs - ): - super(AccessReviewDecisionProperties, self).__init__(**kwargs) - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - 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 = None # type: Optional[str] - self.id_resource_id = None - self.display_name_resource_display_name = None - self.type_principal_type = None # type: Optional[str] - self.id_principal_id = None - self.display_name_principal_display_name = None - - -class AccessReviewDecisionResource(msrest.serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: . - - 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. - - :param type: Required. The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type 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'}, - } - - _subtype_map = { - 'type': {} - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionResource, self).__init__(**kwargs) - self.type = None # type: Optional[str] - 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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) - self.type = 'servicePrincipal' # type: str - 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. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type 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 - ): - super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) - self.type = 'user' # type: str - self.user_principal_name = None - - -class AccessReviewDefaultSettings(msrest.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 - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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, - **kwargs - ): - super(AccessReviewDefaultSettings, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_recurrence_range_type = kwargs.get('type_properties_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_recurrence_pattern_type = kwargs.get('type_properties_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class AccessReviewInstance(msrest.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. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type 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, - **kwargs - ): - super(AccessReviewInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - - -class AccessReviewInstanceListResult(msrest.serialization.Model): - """List of Access Review Instances. - - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewReviewer(msrest.serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "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, - **kwargs - ): - super(AccessReviewReviewer, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - - -class AccessReviewScheduleDefinition(msrest.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 - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type 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. Possible values include: "user", "guestUser", "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. Possible values - include: "eligible", "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param 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)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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. Possible values include: "user", "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__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.backup_reviewers = kwargs.get('backup_reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = kwargs.get('inactive_duration', None) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_settings_recurrence_range_type = kwargs.get('type_properties_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_settings_recurrence_pattern_type = kwargs.get('type_properties_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): - """List of Access Review Schedule Definitions. - - :param value: Access Review Schedule Definition list. - :type value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewScheduleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type 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. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type 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. - Possible values include: "user", "guestUser", "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. Possible values - include: "eligible", "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param 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)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "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__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.backup_reviewers = kwargs.get('backup_reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = kwargs.get('inactive_duration', None) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_settings_recurrence_range_type = kwargs.get('type_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_settings_recurrence_pattern_type = kwargs.get('type_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(msrest.serialization.Model): - """Settings of an Access Review. - - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param 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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type 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, - **kwargs - ): - super(AccessReviewScheduleSettings, self).__init__(**kwargs) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_recurrence_range_type = kwargs.get('type_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_recurrence_pattern_type = kwargs.get('type_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.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 - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type 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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) 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 index 830c5a8f66dd..7f8b5aa1b102 100644 --- 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._authorization_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessReviewDecision(msrest.serialization.Model): @@ -26,21 +28,22 @@ class AccessReviewDecision(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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", "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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", + "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. @@ -48,7 +51,7 @@ class AccessReviewDecision(msrest.serialization.Model): :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -59,7 +62,7 @@ class AccessReviewDecision(msrest.serialization.Model): :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -67,19 +70,18 @@ class AccessReviewDecision(msrest.serialization.Model): :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 - :param type_properties_resource_type: The type of resource.Constant filled by server. Possible - values include: "azureRole". - :type type_properties_resource_type: str or + :ivar type_properties_resource_type: The type of resource.Constant filled by server. Known + values are: "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 - :param type_properties_principal_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type type_properties_principal_type: str or + :ivar type_properties_principal_type: The type of decision target : + User/ServicePrincipal.Constant filled by server. Known values are: "user", "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 @@ -139,10 +141,19 @@ class AccessReviewDecision(msrest.serialization.Model): def __init__( self, *, - decision: Optional[Union[str, "AccessReviewResult"]] = None, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", "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(AccessReviewDecision, self).__init__(**kwargs) self.id = None self.name = None @@ -179,9 +190,9 @@ class AccessReviewDecisionIdentity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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. @@ -208,6 +219,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionIdentity, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -217,10 +230,10 @@ def __init__( class AccessReviewDecisionListResult(msrest.serialization.Model): """List of access review decisions. - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -231,10 +244,17 @@ class AccessReviewDecisionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewDecision"]] = None, + value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewDecisionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -245,21 +265,22 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): 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. Possible - values include: "Approve", "Deny", "NoInfoAvailable". + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :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", "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. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", + "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. @@ -267,7 +288,7 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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. @@ -277,25 +298,25 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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 - :param type_resource_type: The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type type_resource_type: str or + :ivar type_resource_type: The type of resource.Constant filled by server. Known values are: + "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 - :param type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled - by server. Possible values include: "user", "servicePrincipal". - :type type_principal_type: str or + :ivar type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled + by server. Known values are: "user", "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 @@ -349,10 +370,19 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): def __init__( self, *, - decision: Optional[Union[str, "AccessReviewResult"]] = None, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs ): + """ + :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", "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(AccessReviewDecisionProperties, self).__init__(**kwargs) self.recommendation = None self.decision = decision @@ -386,9 +416,9 @@ class AccessReviewDecisionResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType + :ivar type: Required. The type of resource.Constant filled by server. Known values are: + "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. @@ -415,6 +445,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionResource, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -428,9 +460,9 @@ class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity) All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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. @@ -457,6 +489,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.app_id = None @@ -469,9 +503,9 @@ class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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. @@ -498,6 +532,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) self.type = 'user' # type: str self.user_principal_name = None @@ -515,50 +551,50 @@ class AccessReviewDefaultSettings(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :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", "numbered". + :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _validation = { @@ -594,18 +630,65 @@ def __init__( reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_properties_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewDefaultSettings, self).__init__(**kwargs) self.id = None self.name = None @@ -637,15 +720,15 @@ class AccessReviewInstance(msrest.serialization.Model): :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. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime + :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 = { @@ -671,6 +754,12 @@ def __init__( end_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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(AccessReviewInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -683,10 +772,10 @@ def __init__( class AccessReviewInstanceListResult(msrest.serialization.Model): """List of Access Review Instances. - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :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 = { @@ -697,10 +786,17 @@ class AccessReviewInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewInstance"]] = None, + value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -711,10 +807,10 @@ class AccessReviewReviewer(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". + :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", + "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewerType """ @@ -734,6 +830,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ super(AccessReviewReviewer, self).__init__(**kwargs) self.principal_id = principal_id self.principal_type = None @@ -750,99 +850,99 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :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. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: + :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. - Possible values include: "Assigned", "Self", "Managers". + assigned and instead be chosen dynamically. For example managers review or self review. Known + values are: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :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. Possible values include: "user", "guestUser", "servicePrincipal". + to review. Known values are: "user", "guestUser", "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. Possible values - include: "eligible", "active". + :ivar assignment_state: The role assignment state eligible/active to review. Known values are: + "eligible", "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + :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)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :vartype inactive_duration: ~datetime.timedelta + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :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", "numbered". + :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :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. Possible values include: "user", "servicePrincipal". + user/servicePrincipal. Known values are: "user", "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. @@ -910,26 +1010,96 @@ def __init__( display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, - instances: Optional[List["AccessReviewInstance"]] = 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, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_properties_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", + "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", "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(AccessReviewScheduleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -970,11 +1140,11 @@ def __init__( class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): """List of Access Review Schedule Definitions. - :param value: Access Review Schedule Definition list. - :type value: + :ivar value: Access Review Schedule Definition list. + :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -985,10 +1155,17 @@ class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AccessReviewScheduleDefinition"]] = None, + value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -999,99 +1176,99 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :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", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :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. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type 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] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: + :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. - Possible values include: "Assigned", "Self", "Managers". + assigned and instead be chosen dynamically. For example managers review or self review. Known + values are: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :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. - Possible values include: "user", "guestUser", "servicePrincipal". + Known values are: "user", "guestUser", "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. Possible values - include: "eligible", "active". + :ivar assignment_state: The role assignment state eligible/active to review. Known values are: + "eligible", "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + :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)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :vartype inactive_duration: ~datetime.timedelta + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :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", "numbered". + :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :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. - Possible values include: "user", "servicePrincipal". + Known values are: "user", "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. @@ -1153,26 +1330,95 @@ def __init__( display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, - instances: Optional[List["AccessReviewInstance"]] = 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, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) self.display_name = display_name self.status = None @@ -1210,50 +1456,50 @@ def __init__( class AccessReviewScheduleSettings(msrest.serialization.Model): """Settings of an Access Review. - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :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. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :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", "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :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. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :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", "numbered". + :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :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. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or + :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", "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _attribute_map = { @@ -1280,18 +1526,65 @@ def __init__( reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "DefaultDecisionType"]] = 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, "AccessReviewRecurrenceRangeType"]] = 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, "AccessReviewRecurrencePatternType"]] = None, + type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs ): + """ + :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", "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", "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", "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(AccessReviewScheduleSettings, self).__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled @@ -1312,8 +1605,8 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -1323,9 +1616,14 @@ class ErrorDefinition(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDefinitionProperties"] = None, + error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -1337,8 +1635,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -1356,6 +1654,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -1364,14 +1666,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :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 = { @@ -1386,10 +1688,20 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs ): + """ + :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(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -1430,6 +1742,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1440,10 +1754,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :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 = { @@ -1454,10 +1768,16 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :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(OperationListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 index 9fe7178064d5..b430fe8f3b8e 100644 --- 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 @@ -16,6 +16,9 @@ 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 * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'AccessReviewScheduleDefinitionsOperations', @@ -27,3 +30,5 @@ 'AccessReviewInstancesAssignedForMyApprovalOperations', 'AccessReviewInstanceMyDecisionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 index 232c1f8005ff..584884f8dc4e 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,124 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleSettings] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class AccessReviewDefaultSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewDefaultSettingsOperations(object): - """AccessReviewDefaultSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + **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 @@ -56,36 +131,38 @@ def get( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -94,58 +171,62 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace def put( self, - properties, # type: "_models.AccessReviewScheduleSettings" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -154,4 +235,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + 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 index 3437cd4606f3..40f5578efca8 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,95 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceDecisionsOperations(object): - """AccessReviewInstanceDecisionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -62,50 +104,60 @@ def list( :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. + 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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,17 +166,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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 index c48455101f10..d8b6c7a6bd70 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,175 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewDecisionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstanceMyDecisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceMyDecisionsOperations(object): - """AccessReviewInstanceMyDecisionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -62,49 +184,58 @@ def list( :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. + 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 AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,29 +244,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + 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. @@ -149,38 +285,40 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -189,17 +327,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace def patch( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - properties, # type: "_models.AccessReviewDecisionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -209,49 +349,51 @@ def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -260,4 +402,6 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + 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 index fa1686655fbd..73c36e24618e 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,235 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewInstanceOperations(object): - """AccessReviewInstanceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -62,52 +246,55 @@ def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - def reset_decisions( + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -119,52 +306,55 @@ def reset_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore - def apply_decisions( + + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -176,52 +366,55 @@ def apply_decisions( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore - def send_reminders( + + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -233,52 +426,55 @@ def send_reminders( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + - def accept_recommendations( + @distributed_trace + def accept_recommendations( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -290,40 +486,43 @@ def accept_recommendations( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + 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 index 793f76110420..58d98faef12f 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,125 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class AccessReviewInstancesAssignedForMyApprovalOperations(object): - """AccessReviewInstancesAssignedForMyApprovalOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AccessReviewInstancesAssignedForMyApprovalOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,48 +132,56 @@ def list( :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. + 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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,28 +190,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + 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. @@ -142,37 +228,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -181,4 +269,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index 4ab41b51436a..618108031299 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,129 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class AccessReviewInstancesOperations(object): - """AccessReviewInstancesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AccessReviewInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - schedule_definition_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,49 +136,58 @@ def list( :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. + 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 AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,28 +196,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + 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. @@ -143,38 +234,40 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -183,4 +276,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + 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 index ad4b826a033e..5288ae74ae75 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,136 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): - """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: """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. + 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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +144,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore 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 index 53c36160607d..f6b79dd63225 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,292 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AccessReviewScheduleDefinitionsOperations(object): - """AccessReviewScheduleDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: """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. + 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 AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +300,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + 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. @@ -136,37 +335,39 @@ def get_by_id( :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -175,14 +376,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -192,98 +395,103 @@ def delete_by_id( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace def create_or_update_by_id( self, - schedule_definition_id, # type: str - properties, # type: "_models.AccessReviewScheduleDefinitionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties :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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -292,14 +500,16 @@ def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -309,40 +519,43 @@ def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, response) + 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'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + 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 index 52fa6e32a55b..156fd947cfe2 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,123 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.authorization.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + 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, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +131,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) 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'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py new file mode 100644 index 000000000000..d9033c6b26a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py @@ -0,0 +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. +# 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 * # type: ignore # 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 new file mode 100644 index 000000000000..8813840262f6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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=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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :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(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 + ) + 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.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 + ) + + + 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/python/protocol/quickstart + + :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): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AuthorizationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..7fd410e3c40c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :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 = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + 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 # type: Any + ): + # type: (...) -> 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 new file mode 100644 index 000000000000..e4eaeedeb329 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json @@ -0,0 +1,112 @@ +{ + "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": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 = "1.0.0b1" 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 new file mode 100644 index 000000000000..069a548e077c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..228ae9a1f766 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py @@ -0,0 +1,159 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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=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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :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(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 + ) + 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.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 + ) + + + 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/python/protocol/quickstart + + :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) -> 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 new file mode 100644 index 000000000000..b3d884766ca4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :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 = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..bae808ba2563 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py new file mode 100644 index 000000000000..59911071f48d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -0,0 +1,163 @@ +# 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, 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_07_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") + + + @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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace_async + async def put( + self, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..91fd16e48005 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,135 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_07_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..a59bfb3337cb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,143 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..6dce19c56872 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,284 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..b635505c9d11 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py @@ -0,0 +1,342 @@ +# 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, 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") + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + 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 new file mode 100644 index 000000000000..03ffa8d3a2c4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,200 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..965b53e265c8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py @@ -0,0 +1,275 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..3d49a0168887 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,131 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_07_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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..af3fa70c9237 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,374 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + 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 new file mode 100644 index 000000000000..e58758009ee6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py @@ -0,0 +1,122 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """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 OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..b0e028a4d305 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,133 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_07_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..df6c99cea2d7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, + AccessReviewActorIdentityType, + AccessReviewApplyResult, + AccessReviewInstanceReviewersType, + AccessReviewInstanceStatus, + AccessReviewRecurrencePatternType, + AccessReviewRecurrenceRangeType, + AccessReviewResult, + AccessReviewReviewerType, + AccessReviewScheduleDefinitionReviewersType, + AccessReviewScheduleDefinitionStatus, + AccessReviewScopeAssignmentState, + AccessReviewScopePrincipalType, + DecisionResourceType, + DecisionTargetType, + DefaultDecisionType, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..61808cdeca57 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py @@ -0,0 +1,160 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 new file mode 100644 index 000000000000..62627223c12d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py @@ -0,0 +1,2061 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AccessReviewContactedReviewer(msrest.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 + ): + """ + """ + super(AccessReviewContactedReviewer, self).__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(msrest.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 + ): + """ + :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(AccessReviewContactedReviewerListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecision(msrest.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", "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", "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", + "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", "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", "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.Constant filled by server. Known + values are: "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.Constant filled by server. Known values are: "user", "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 + ): + """ + :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", "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(AccessReviewDecision, self).__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 = None # type: Optional[str] + self.id_properties_resource_id = None + self.display_name_properties_resource_display_name = None + self.type_properties_principal_type = None # type: Optional[str] + self.id_properties_principal_id = None + self.display_name_properties_principal_display_name = None + + +class AccessReviewDecisionIdentity(msrest.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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionIdentity, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.id = None + self.display_name = None + + +class AccessReviewDecisionListResult(msrest.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 + ): + """ + :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(AccessReviewDecisionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecisionProperties(msrest.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", "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", "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", + "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", "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", "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.Constant filled by server. Known values are: + "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.Constant filled + by server. Known values are: "user", "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 + ): + """ + :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", "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(AccessReviewDecisionProperties, self).__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 = None # type: Optional[str] + self.id_resource_id = None + self.display_name_resource_display_name = None + self.type_principal_type = None # type: Optional[str] + self.id_principal_id = None + self.display_name_principal_display_name = None + + +class AccessReviewDecisionResource(msrest.serialization.Model): + """Target of the decision. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: . + + 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: Required. The type of resource.Constant filled by server. Known values are: + "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'}, + } + + _subtype_map = { + 'type': {} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewDecisionResource, self).__init__(**kwargs) + self.type = None # type: Optional[str] + 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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) + self.type = 'servicePrincipal' # type: str + 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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) + self.type = 'user' # type: str + self.user_principal_name = None + + +class AccessReviewDefaultSettings(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(AccessReviewDefaultSettings, self).__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(msrest.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", "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", "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 + ): + """ + :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(AccessReviewInstance, self).__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(msrest.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 + ): + """ + :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(AccessReviewInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewInstanceProperties(msrest.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", "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", "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 + ): + """ + :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(AccessReviewInstanceProperties, self).__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(msrest.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", + "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 + ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ + super(AccessReviewReviewer, self).__init__(**kwargs) + self.principal_id = principal_id + self.principal_type = None + + +class AccessReviewScheduleDefinition(msrest.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", "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", "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", + "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", "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", "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", "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", "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", "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__( + 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 + ): + """ + :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", "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", + "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", "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(AccessReviewScheduleDefinition, self).__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(msrest.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 + ): + """ + :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(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewScheduleDefinitionProperties(msrest.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", "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", "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", "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", "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", "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", "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", "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", "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__( + 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 + ): + """ + :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", "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", "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", "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(AccessReviewScheduleDefinitionProperties, self).__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(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(AccessReviewScheduleSettings, self).__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(msrest.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 + ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties + """ + super(ErrorDefinition, self).__init__(**kwargs) + self.error = error + + +class ErrorDefinitionProperties(msrest.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 + ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ + super(ErrorDefinitionProperties, self).__init__(**kwargs) + self.message = None + self.code = code + + +class Operation(msrest.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 + ): + """ + :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(Operation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class OperationDisplay(msrest.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 + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.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 + ): + """ + :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(OperationListResult, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..bae808ba2563 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..f8d45b1a2052 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py @@ -0,0 +1,240 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleSettings] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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") + + + @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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace + def put( + self, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + 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 new file mode 100644 index 000000000000..c90ae9490f48 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,175 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..a69af0c968b7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,187 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..3d9e86ae9ac2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,407 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewDecisionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..61c0b0496471 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py @@ -0,0 +1,528 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + 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 new file mode 100644 index 000000000000..0a667bd68f3e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,274 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..acb02f1cb3ab --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py @@ -0,0 +1,398 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewInstanceProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def create( + self, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..88e1c36742b9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,165 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..b7774259a209 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,561 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _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, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + 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 new file mode 100644 index 000000000000..11dfdd7bc786 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py @@ -0,0 +1,152 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """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 OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..507f36e1dea8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,171 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..d9033c6b26a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/__init__.py @@ -0,0 +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. +# 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 * # type: ignore # 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 new file mode 100644 index 000000000000..795e8677409c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py @@ -0,0 +1,256 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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=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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :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(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 + ) + 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 + ) + + + 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/python/protocol/quickstart + + :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): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AuthorizationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..319e564e6d45 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :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 = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + 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 # type: Any + ): + # type: (...) -> 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 new file mode 100644 index 000000000000..89aa1e82d4e6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json @@ -0,0 +1,126 @@ +{ + "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": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.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: + formatted_components = 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 = "1.0.0b1" 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 new file mode 100644 index 000000000000..069a548e077c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..6022bc8308b6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py @@ -0,0 +1,253 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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=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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :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(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 + ) + 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 + ) + + + 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/python/protocol/quickstart + + :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) -> 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 new file mode 100644 index 000000000000..14e2a2e98c2b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :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 = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..16c9bec8c134 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..69b069f5b005 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -0,0 +1,163 @@ +# 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, 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") + + + @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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace_async + async def put( + self, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..4ee5f04b00a6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py @@ -0,0 +1,109 @@ +# 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, 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_history_definition_instance_operations import build_generate_download_uri_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewHistoryDefinitionInstanceOperations: + """ + .. 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_history_definition_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") + + + @distributed_trace_async + async def generate_download_uri( + self, + history_definition_id: str, + instance_id: str, + **kwargs: Any + ) -> _models.AccessReviewHistoryInstance: + """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day + and can be retrieved by fetching the accessReviewHistoryDefinition object. + + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param instance_id: The id of the access review history definition instance to generate a URI + for. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryInstance] + + + request = build_generate_download_uri_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_download_uri.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri"} # 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/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..327992171ff5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py @@ -0,0 +1,130 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_history_definition_instances_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewHistoryDefinitionInstancesOperations: + """ + .. 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_history_definition_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") + + + @distributed_trace + def list( + self, + history_definition_id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewHistoryDefinitionInstanceListResult]: + """Get access review history definition instances by definition Id. + + :param history_definition_id: The id of the access review history definition. + :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 AccessReviewHistoryDefinitionInstanceListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + history_definition_id=history_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances"} # type: ignore 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/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py new file mode 100644 index 000000000000..e178eb45e631 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py @@ -0,0 +1,167 @@ +# 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, 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_history_definition_operations import build_create_request, build_delete_by_id_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewHistoryDefinitionOperations: + """ + .. 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_history_definition` 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") + + + @distributed_trace_async + async def create( + self, + history_definition_id: str, + properties: _models.AccessReviewHistoryDefinitionProperties, + **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. + :type history_definition_id: str + :param properties: Access review history definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + _json = self._serialize.body(properties, 'AccessReviewHistoryDefinitionProperties') + + request = build_create_request( + subscription_id=self._config.subscription_id, + history_definition_id=history_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + 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. + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..53c4c7e6e2fa --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py @@ -0,0 +1,193 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_history_definitions_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 AccessReviewHistoryDefinitionsOperations: + """ + .. 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_history_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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewHistoryDefinitionListResult]: + """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 AccessReviewHistoryDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions"} # type: ignore + + @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. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # type: ignore + 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 new file mode 100644 index 000000000000..ee752f6438d6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,135 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..c243edf75263 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,143 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..f5e5380a74c5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,284 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..08f81f74fa31 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py @@ -0,0 +1,342 @@ +# 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, 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") + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_reset_decisions_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_apply_decisions_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_send_reminders_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # 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/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..c449bc6597a9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,200 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py new file mode 100644 index 000000000000..91c6f0504a4a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py @@ -0,0 +1,275 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + 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 new file mode 100644 index 000000000000..1270b15f630f --- /dev/null +++ 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 @@ -0,0 +1,131 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..5d30534077cc --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,374 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + 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 new file mode 100644 index 000000000000..214a3eb578cd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py @@ -0,0 +1,122 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """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 OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py new file mode 100644 index 000000000000..63eea0f97190 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py @@ -0,0 +1,169 @@ +# 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, 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_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 ScopeAccessReviewDefaultSettingsOperations: + """ + .. 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:`scope_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") + + + @distributed_trace_async + async def get( + self, + scope: str, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param scope: The scope of the resource. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async + async def put( + self, + scope: str, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param scope: The scope of the resource. + :type scope: str + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..0977f4fec196 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py @@ -0,0 +1,112 @@ +# 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, 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_access_review_history_definition_instance_operations import build_generate_download_uri_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ScopeAccessReviewHistoryDefinitionInstanceOperations: + """ + .. 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:`scope_access_review_history_definition_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") + + + @distributed_trace_async + async def generate_download_uri( + self, + scope: str, + history_definition_id: str, + instance_id: str, + **kwargs: Any + ) -> _models.AccessReviewHistoryInstance: + """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day + and can be retrieved by fetching the accessReviewHistoryDefinition object. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param instance_id: The id of the access review history definition instance to generate a URI + for. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_download_uri.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..9e2b18136bed --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py @@ -0,0 +1,133 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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._scope_access_review_history_definition_instances_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ScopeAccessReviewHistoryDefinitionInstancesOperations: + """ + .. 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:`scope_access_review_history_definition_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") + + + @distributed_trace + def list( + self, + scope: str, + history_definition_id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewHistoryDefinitionInstanceListResult]: + """Get access review history definition instances by definition Id. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 AccessReviewHistoryDefinitionInstanceListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + 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) # type: ignore + + else: + + request = build_list_request( + scope=scope, + history_definition_id=history_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances"} # type: ignore 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/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py new file mode 100644 index 000000000000..8b9039935d8b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py @@ -0,0 +1,173 @@ +# 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, 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_access_review_history_definition_operations import build_create_request, build_delete_by_id_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ScopeAccessReviewHistoryDefinitionOperations: + """ + .. 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:`scope_access_review_history_definition` 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") + + + @distributed_trace_async + async def create( + self, + scope: str, + history_definition_id: str, + properties: _models.AccessReviewHistoryDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewHistoryDefinition: + """Create a scheduled or one-time Access Review History Definition. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param properties: Access review history definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + _json = self._serialize.body(properties, 'AccessReviewHistoryDefinitionProperties') + + request = build_create_request( + scope=scope, + history_definition_id=history_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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: + """Delete an access review history definition. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..17b01c7e5e6d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py @@ -0,0 +1,199 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_access_review_history_definitions_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 ScopeAccessReviewHistoryDefinitionsOperations: + """ + .. 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:`scope_access_review_history_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") + + + @distributed_trace + def list( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewHistoryDefinitionListResult]: + """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are + only available for 30 days after creation. + + :param scope: The scope of the resource. + :type scope: str + :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 AccessReviewHistoryDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + scope: str, + history_definition_id: str, + **kwargs: Any + ) -> _models.AccessReviewHistoryDefinition: + """Get access review history definition by definition Id. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..28a0d8d5c958 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,138 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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._scope_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 ScopeAccessReviewInstanceContactedReviewersOperations: + """ + .. 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:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + 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) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore 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/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..0ef6b1a2194d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py @@ -0,0 +1,146 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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._scope_access_review_instance_decisions_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ScopeAccessReviewInstanceDecisionsOperations: + """ + .. 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:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py new file mode 100644 index 000000000000..88134d846157 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py @@ -0,0 +1,366 @@ +# 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, 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_access_review_instance_operations import build_apply_decisions_request, build_record_all_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 ScopeAccessReviewInstanceOperations: + """ + .. 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:`scope_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") + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements + 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. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + + + @distributed_trace_async + async def record_all_decisions( # pylint: disable=inconsistent-return-statements + self, + scope: str, + schedule_definition_id: str, + id: str, + properties: _models.RecordAllDecisionsProperties, + **kwargs: Any + ) -> None: + """An action to approve/deny all decisions for a review with certain filters. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Record all decisions payload. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(properties, 'RecordAllDecisionsProperties') + + request = build_record_all_decisions_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.record_all_decisions.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + record_all_decisions.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions"} # 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: + """An action to reset all decisions for an access review instance. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # 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: + """An action to apply all decisions for an access review instance. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # 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: + """An action to send reminders for an access review instance. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py new file mode 100644 index 000000000000..69128f5f45b9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py @@ -0,0 +1,284 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_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 ScopeAccessReviewInstancesOperations: + """ + .. 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:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + scope: str, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Get access review instances. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + scope: str, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # 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/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..749804832f3c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py @@ -0,0 +1,389 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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_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 ScopeAccessReviewScheduleDefinitionsOperations: + """ + .. 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:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewScheduleDefinitionListResult]: + """Get access review schedule definitions. + + :param scope: The scope of the resource. + :type scope: 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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + scope: str, + schedule_definition_id: str, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Get single access review definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # 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: + """Delete access review schedule definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + scope: str, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + 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, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements + self, + scope: str, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Stop access review definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + 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 new file mode 100644 index 000000000000..56185f865d09 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,133 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..5d6734a75e4f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/__init__.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. +# -------------------------------------------------------------------------- + +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, + AccessReviewActorIdentityType, + AccessReviewApplyResult, + AccessReviewDecisionInsightType, + AccessReviewDecisionPrincipalResourceMembershipType, + AccessReviewHistoryDefinitionStatus, + AccessReviewInstanceReviewersType, + AccessReviewInstanceStatus, + AccessReviewRecurrencePatternType, + AccessReviewRecurrenceRangeType, + AccessReviewResult, + AccessReviewReviewerType, + AccessReviewScheduleDefinitionReviewersType, + AccessReviewScheduleDefinitionStatus, + AccessReviewScopeAssignmentState, + AccessReviewScopePrincipalType, + DecisionResourceType, + DecisionTargetType, + DefaultDecisionType, + RecordAllDecisionsResult, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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() \ No newline at end of file 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/v2021_12_01_preview/models/_authorization_management_client_enums.py new file mode 100644 index 000000000000..a5fa20dcbc0f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_authorization_management_client_enums.py @@ -0,0 +1,187 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 AccessReviewDecisionInsightType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of insight + """ + + USER_SIGN_IN_INSIGHT = "userSignInInsight" + +class AccessReviewDecisionPrincipalResourceMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + DIRECT = "direct" + INDIRECT = "indirect" + +class AccessReviewHistoryDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This read-only field specifies the of the requested review history data. This is either + requested, in-progress, done or error. + """ + + REQUESTED = "Requested" + IN_PROGRESS = "InProgress" + DONE = "Done" + ERROR = "Error" + +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): + """Represents a reviewer's decision for a given review + """ + + 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" + +class RecordAllDecisionsResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The decision to make. Approvers can take action of Approve/Deny + """ + + APPROVE = "Approve" + DENY = "Deny" 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 new file mode 100644 index 000000000000..d24a3bd91e3a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py @@ -0,0 +1,2933 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AccessReviewContactedReviewer(msrest.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 + ): + """ + """ + super(AccessReviewContactedReviewer, self).__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(msrest.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 + ): + """ + :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(AccessReviewContactedReviewerListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecision(msrest.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", "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", "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", + "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", "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", "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. Known values are: "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.Constant filled by server. Known values are: "user", "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__( + 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 + ): + """ + :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", "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. Known values are: "azureRole". + :paramtype type_properties_resource_type: str or + ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType + """ + super(AccessReviewDecision, self).__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 = None # type: Optional[str] + self.id_properties_principal_id = None + self.display_name_properties_principal_display_name = None + + +class AccessReviewDecisionIdentity(msrest.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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionIdentity, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.id = None + self.display_name = None + + +class AccessReviewDecisionInsight(msrest.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.Constant filled by server. Known values are: + "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 + ): + """ + """ + super(AccessReviewDecisionInsight, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.type_properties_type = None # type: Optional[str] + self.insight_created_date_time = None + + +class AccessReviewDecisionInsightProperties(msrest.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: Required. The type of insight.Constant filled by server. Known values are: + "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 + ): + """ + """ + super(AccessReviewDecisionInsightProperties, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.insight_created_date_time = None + + +class AccessReviewDecisionListResult(msrest.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 + ): + """ + :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(AccessReviewDecisionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecisionProperties(msrest.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", "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", "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", + "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", "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", "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. Known values are: "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.Constant filled + by server. Known values are: "user", "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 + ): + """ + :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", "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. Known values are: "azureRole". + :paramtype type_resource_type: str or + ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType + """ + super(AccessReviewDecisionProperties, self).__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 = None # type: Optional[str] + 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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) + self.type = 'servicePrincipal' # type: str + 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: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Known values are: "user", "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 + ): + """ + """ + super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) + self.type = 'user' # type: str + 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: Required. The type of insight.Constant filled by server. Known values are: + "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 + ): + """ + """ + super(AccessReviewDecisionUserSignInInsightProperties, self).__init__(**kwargs) + self.type = 'userSignInInsight' # type: str + self.last_sign_in_date_time = None + + +class AccessReviewDefaultSettings(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(AccessReviewDefaultSettings, self).__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(msrest.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.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", "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", "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", "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", + "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 + ): + """ + :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", "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", "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(AccessReviewHistoryDefinition, self).__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(msrest.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 + ): + """ + :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(AccessReviewHistoryDefinitionInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewHistoryDefinitionListResult(msrest.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 + ): + """ + :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(AccessReviewHistoryDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewHistoryDefinitionProperties(msrest.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.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", "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", "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", "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", + "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 + ): + """ + :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", "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", "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(AccessReviewHistoryDefinitionProperties, self).__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(msrest.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", "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 + ): + """ + :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(AccessReviewHistoryInstance, self).__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(msrest.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", "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", "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 + ): + """ + :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(AccessReviewInstance, self).__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(msrest.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 + ): + """ + :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(AccessReviewInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewInstanceProperties(msrest.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", "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", "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 + ): + """ + :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(AccessReviewInstanceProperties, self).__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(msrest.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", + "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 + ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ + super(AccessReviewReviewer, self).__init__(**kwargs) + self.principal_id = principal_id + self.principal_type = None + + +class AccessReviewScheduleDefinition(msrest.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", "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", "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", + "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", "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", "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", "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", "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", "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__( + 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 + ): + """ + :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", "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", + "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", "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(AccessReviewScheduleDefinition, self).__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(msrest.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 + ): + """ + :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(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewScheduleDefinitionProperties(msrest.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", "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", "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", "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", "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", "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", "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", "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", "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__( + 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 + ): + """ + :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", "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", "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", "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(AccessReviewScheduleDefinitionProperties, self).__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(msrest.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", "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", "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", "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 + ): + """ + :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", "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", "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", "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(AccessReviewScheduleSettings, self).__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(msrest.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", "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", "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 + ): + """ + :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(AccessReviewScope, self).__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(msrest.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 + ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties + """ + super(ErrorDefinition, self).__init__(**kwargs) + self.error = error + + +class ErrorDefinitionProperties(msrest.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 + ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ + super(ErrorDefinitionProperties, self).__init__(**kwargs) + self.message = None + self.code = code + + +class Operation(msrest.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 + ): + """ + :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(Operation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class OperationDisplay(msrest.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 + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.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 + ): + """ + :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(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RecordAllDecisionsProperties(msrest.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", "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 + ): + """ + :keyword decision: The decision to make. Approvers can take action of Approve/Deny. Known + values are: "Approve", "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(RecordAllDecisionsProperties, self).__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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..16c9bec8c134 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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/v2021_12_01_preview/operations/_access_review_default_settings_operations.py new file mode 100644 index 000000000000..6263d2a1594c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py @@ -0,0 +1,240 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewScheduleSettings] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +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.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") + + + @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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + + @distributed_trace + def put( + self, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # 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/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..0ff6ef64ed60 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py @@ -0,0 +1,149 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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_generate_download_uri_request( + subscription_id: str, + history_definition_id: str, + instance_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, 'str'), + "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 AccessReviewHistoryDefinitionInstanceOperations: + """ + .. 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 + :attr:`access_review_history_definition_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") + + + @distributed_trace + def generate_download_uri( + self, + history_definition_id: str, + instance_id: str, + **kwargs: Any + ) -> _models.AccessReviewHistoryInstance: + """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day + and can be retrieved by fetching the accessReviewHistoryDefinition object. + + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param instance_id: The id of the access review history definition instance to generate a URI + for. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryInstance] + + + request = build_generate_download_uri_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_download_uri.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri"} # 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/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..d0c5ad1ae5f2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py @@ -0,0 +1,168 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 AccessReviewHistoryDefinitionInstancesOperations: + """ + .. 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 + :attr:`access_review_history_definition_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") + + + @distributed_trace + def list( + self, + history_definition_id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewHistoryDefinitionInstanceListResult]: + """Get access review history definition instances by definition Id. + + :param history_definition_id: The id of the access review history definition. + :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 AccessReviewHistoryDefinitionInstanceListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + history_definition_id=history_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances"} # type: ignore 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/v2021_12_01_preview/operations/_access_review_history_definition_operations.py new file mode 100644 index 000000000000..103c51c816c9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py @@ -0,0 +1,248 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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( + subscription_id: str, + history_definition_id: str, + *, + json: Optional[_models.AccessReviewHistoryDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_by_id_request( + subscription_id: str, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 + ) + +class AccessReviewHistoryDefinitionOperations: + """ + .. 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 + :attr:`access_review_history_definition` 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") + + + @distributed_trace + def create( + self, + history_definition_id: str, + properties: _models.AccessReviewHistoryDefinitionProperties, + **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. + :type history_definition_id: str + :param properties: Access review history definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + _json = self._serialize.body(properties, 'AccessReviewHistoryDefinitionProperties') + + request = build_create_request( + subscription_id=self._config.subscription_id, + history_definition_id=history_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + 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. + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..e38cf878b61d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py @@ -0,0 +1,267 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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'), + "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 AccessReviewHistoryDefinitionsOperations: + """ + .. 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 + :attr:`access_review_history_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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewHistoryDefinitionListResult]: + """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 AccessReviewHistoryDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions"} # type: ignore + + @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. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..ffced560db8f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,175 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..c700fcc9c890 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,187 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py new file mode 100644 index 000000000000..a993822988b5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,407 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + *, + json: Optional[_models.AccessReviewDecisionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +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.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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: _models.AccessReviewDecisionProperties, + **kwargs: Any + ) -> _models.AccessReviewDecision: + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecision] + + _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, + template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2021_12_01_preview/operations/_access_review_instance_operations.py new file mode 100644 index 000000000000..9b60eee0c7f4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py @@ -0,0 +1,528 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_reset_decisions_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_apply_decisions_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_send_reminders_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # type: ignore + + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # 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/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..58092ffe7a67 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,274 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2021_12_01_preview/operations/_access_review_instances_operations.py new file mode 100644 index 000000000000..d98466181633 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py @@ -0,0 +1,398 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + schedule_definition_id: str, + id: str, + *, + json: Optional[_models.AccessReviewInstanceProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstancesOperations: + """ + .. 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 + :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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @distributed_trace + def create( + self, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # 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/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..4d3eaddb9ff8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,165 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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_12_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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..45803e08b427 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,561 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + schedule_definition_id: str, + *, + json: Optional[_models.AccessReviewScheduleDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + subscription_id: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: + """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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_by_id_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + subscription_id=self._config.subscription_id, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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}"} # type: ignore + + + @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. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request( + subscription_id=self._config.subscription_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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"} # 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/v2021_12_01_preview/operations/_operations.py new file mode 100644 index 000000000000..0a77ed618c9a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py @@ -0,0 +1,152 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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_12_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """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 OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py new file mode 100644 index 000000000000..3d4907a615b5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py @@ -0,0 +1,246 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + *, + json: Optional[_models.AccessReviewScheduleSettings] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class ScopeAccessReviewDefaultSettingsOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def get( + self, + scope: str, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param scope: The scope of the resource. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace + def put( + self, + scope: str, + properties: _models.AccessReviewScheduleSettings, + **kwargs: Any + ) -> _models.AccessReviewDefaultSettings: + """Get access review default settings for the subscription. + + :param scope: The scope of the resource. + :type scope: str + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDefaultSettings] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # 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/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..90550200ad71 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py @@ -0,0 +1,152 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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_generate_download_uri_request( + scope: str, + history_definition_id: str, + instance_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewHistoryDefinitionInstanceOperations: + """ + .. 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 + :attr:`scope_access_review_history_definition_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") + + + @distributed_trace + def generate_download_uri( + self, + scope: str, + history_definition_id: str, + instance_id: str, + **kwargs: Any + ) -> _models.AccessReviewHistoryInstance: + """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day + and can be retrieved by fetching the accessReviewHistoryDefinition object. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param instance_id: The id of the access review history definition instance to generate a URI + for. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_download_uri.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri"} # 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/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..5c3e344e9972 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py @@ -0,0 +1,171 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewHistoryDefinitionInstancesOperations: + """ + .. 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 + :attr:`scope_access_review_history_definition_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") + + + @distributed_trace + def list( + self, + scope: str, + history_definition_id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewHistoryDefinitionInstanceListResult]: + """Get access review history definition instances by definition Id. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 AccessReviewHistoryDefinitionInstanceListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + 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) # type: ignore + + else: + + request = build_list_request( + scope=scope, + history_definition_id=history_definition_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances"} # type: ignore 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/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py new file mode 100644 index 000000000000..850799c28d94 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py @@ -0,0 +1,254 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + history_definition_id: str, + *, + json: Optional[_models.AccessReviewHistoryDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_by_id_request( + scope: str, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 + ) + +class ScopeAccessReviewHistoryDefinitionOperations: + """ + .. 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 + :attr:`scope_access_review_history_definition` 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") + + + @distributed_trace + def create( + self, + scope: str, + history_definition_id: str, + properties: _models.AccessReviewHistoryDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewHistoryDefinition: + """Create a scheduled or one-time Access Review History Definition. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :type history_definition_id: str + :param properties: Access review history definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + _json = self._serialize.body(properties, 'AccessReviewHistoryDefinitionProperties') + + request = build_create_request( + scope=scope, + history_definition_id=history_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + scope: str, + history_definition_id: str, + **kwargs: Any + ) -> None: + """Delete an access review history definition. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..51f497a35b17 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py @@ -0,0 +1,273 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + history_definition_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewHistoryDefinitionsOperations: + """ + .. 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 + :attr:`scope_access_review_history_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") + + + @distributed_trace + def list( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewHistoryDefinitionListResult]: + """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are + only available for 30 days after creation. + + :param scope: The scope of the resource. + :type scope: str + :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 AccessReviewHistoryDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewHistoryDefinitions"} # type: ignore + + @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. + + :param scope: The scope of the resource. + :type scope: str + :param history_definition_id: The id of the access review history definition. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewHistoryDefinition] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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('AccessReviewHistoryDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}"} # 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/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..cbc981322bdd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,178 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewInstanceContactedReviewersOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + 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) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore 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/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..a7f244b213b0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py @@ -0,0 +1,190 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewInstanceDecisionsOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewDecisionListResult]: + """Get access review instance decisions. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewDecisionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore 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/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py new file mode 100644 index 000000000000..c32df330f81e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py @@ -0,0 +1,562 @@ +# 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 msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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_record_all_decisions_request( + scope: str, + schedule_definition_id: str, + id: str, + *, + json: Optional[_models.RecordAllDecisionsProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_reset_decisions_request( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewInstanceOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements + 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. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + + + @distributed_trace + def record_all_decisions( # pylint: disable=inconsistent-return-statements + self, + scope: str, + schedule_definition_id: str, + id: str, + properties: _models.RecordAllDecisionsProperties, + **kwargs: Any + ) -> None: + """An action to approve/deny all decisions for a review with certain filters. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Record all decisions payload. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(properties, 'RecordAllDecisionsProperties') + + request = build_record_all_decisions_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.record_all_decisions.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + record_all_decisions.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions"} # type: ignore + + + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements + 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. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + + + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements + 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. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + + + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements + 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. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # 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/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py new file mode 100644 index 000000000000..7285472951a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py @@ -0,0 +1,407 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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, + schedule_definition_id: str, + id: str, + *, + json: Optional[_models.AccessReviewInstanceProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + +class ScopeAccessReviewInstancesOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewInstanceListResult]: + """Get access review instances. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace + def get_by_id( + self, + scope: str, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Get access review instances. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + + + @distributed_trace + def create( + self, + scope: str, + schedule_definition_id: str, + id: str, + properties: _models.AccessReviewInstanceProperties, + **kwargs: Any + ) -> _models.AccessReviewInstance: + """Update access review instance. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :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 + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewInstance] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + scope=scope, + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # 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/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..dffe039c45da --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py @@ -0,0 +1,576 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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( + scope: str, + schedule_definition_id: str, + *, + json: Optional[_models.AccessReviewScheduleDefinitionProperties] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + scope: str, + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _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 = _format_url_section(_url, **path_format_arguments) + + # 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 ScopeAccessReviewScheduleDefinitionsOperations: + """ + .. 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 + :attr:`scope_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") + + + @distributed_trace + def list( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.AccessReviewScheduleDefinitionListResult]: + """Get access review schedule definitions. + + :param scope: The scope of the resource. + :type scope: 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 AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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/accessReviewScheduleDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + scope: str, + schedule_definition_id: str, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Get single access review definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + scope: str, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Delete access review schedule definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + scope: str, + schedule_definition_id: str, + properties: _models.AccessReviewScheduleDefinitionProperties, + **kwargs: Any + ) -> _models.AccessReviewScheduleDefinition: + """Create or Update access review schedule definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :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 + } + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewScheduleDefinition] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + 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, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements + self, + scope: str, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Stop access review definition. + + :param scope: The scope of the resource. + :type scope: str + :param schedule_definition_id: The id of the access review schedule definition. + :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 + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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': "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # 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/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..0bcd945a340f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,171 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._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 = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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_12_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") + + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable[_models.AccessReviewContactedReviewerListResult]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :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 AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessReviewContactedReviewerListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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) # type: ignore + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = 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"} # type: ignore 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file