diff --git a/sdk/authorization/azure-mgmt-authorization/_meta.json b/sdk/authorization/azure-mgmt-authorization/_meta.json index 93b83d2d4425..684d0005e1c4 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.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "ac1c84fa8c897975b88a38a66dd64d54312a1422", + "commit": "6a78d88051b539ec5ed5383a4705125769793883", "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 --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.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..ebb2f1ff2513 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 @@ -23,7 +23,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): @@ -69,12 +68,10 @@ def __init__( 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._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( @@ -101,6 +98,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 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` """ if api_version == '2015-06-01': from .v2015_06_01 import models @@ -135,6 +133,9 @@ 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 raise ValueError("API version {} is not available".format(api_version)) @property @@ -143,12 +144,15 @@ def access_review_default_settings(self): * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` + * 2021-07-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 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))) @@ -159,28 +163,47 @@ def access_review_instance(self): * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` + * 2021-07-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 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` + """ + 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 + 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` """ 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 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 +214,15 @@ 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` """ 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 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 +233,15 @@ def access_review_instances(self): * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` + * 2021-07-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 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 +252,15 @@ 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` """ 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 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 +271,15 @@ def access_review_schedule_definitions(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` + * 2021-07-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 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 +290,15 @@ 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` """ 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 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))) @@ -327,6 +365,7 @@ 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` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': @@ -335,6 +374,8 @@ 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 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))) @@ -607,6 +648,19 @@ 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` + """ + 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 + 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..e357b2797662 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 @@ -68,4 +68,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..5126f68f9520 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,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ 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): @@ -67,12 +67,10 @@ def __init__( 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._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( @@ -99,6 +97,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 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` """ if api_version == '2015-06-01': from ..v2015_06_01 import models @@ -133,6 +132,9 @@ 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 raise ValueError("API version {} is not available".format(api_version)) @property @@ -141,12 +143,15 @@ def access_review_default_settings(self): * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` + * 2021-07-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 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))) @@ -157,28 +162,47 @@ def access_review_instance(self): * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` + * 2021-07-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 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` + """ + 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 + 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` """ 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 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 +213,15 @@ 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` """ 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 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 +232,15 @@ def access_review_instances(self): * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` + * 2021-07-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 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 +251,15 @@ 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` """ 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 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 +270,15 @@ def access_review_schedule_definitions(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` + * 2021-07-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 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 +289,15 @@ 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` """ 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 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))) @@ -325,6 +364,7 @@ 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` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': @@ -333,6 +373,8 @@ 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 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))) @@ -605,6 +647,19 @@ 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` + """ + 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 + 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..dda803e9f700 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 @@ -64,4 +64,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/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py index ae11ad3e4d97..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..2adc4372a416 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,77 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse 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 . 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): +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 """ 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.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: 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..dbfb6e8bf0fe 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..d7f12a6ea59b 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..0f26e7bd7b57 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest 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 .. 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): +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 """ 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.classic_administrators = ClassicAdministratorsOperations( - 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..bea031c2b41a 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..35f33884b3e9 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """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"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +100,13 @@ async def get_next(next_link=None): 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 ) 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..2a13108c87ae 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,18 +6,12 @@ # 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 + __all__ = [ 'ClassicAdministrator', 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..302c397c7bdf 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 @@ -15,16 +15,16 @@ 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 +45,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 +68,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 = { @@ -74,6 +86,12 @@ def __init__( 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 +122,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +167,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +180,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 = { @@ -172,5 +194,9 @@ def __init__( error: Optional["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/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py index d1a65c48396f..a851af0e9999 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 @@ -5,23 +5,56 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2015-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ClassicAdministratorsOperations(object): """ClassicAdministratorsOperations operations. @@ -45,16 +78,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,34 +97,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +132,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..7a6181bc439c 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,96 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - -class AuthorizationManagementClient(object): +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 """ 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.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_administrator = GlobalAdministratorOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: 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..c6ee90911018 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..b3e0166fa9a9 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..8aa5fe15ea62 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,96 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AuthorizationManagementClient(object): +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 """ 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.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_administrator = GlobalAdministratorOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - 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..37b15918db1e 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..63b247dc32f5 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """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"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +100,13 @@ async def get_next(next_link=None): 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 ) 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..00c7dfb8ffae 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def elevate_access( self, **kwargs: Any @@ -56,30 +61,24 @@ async def elevate_access( 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 - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_elevate_access_request( + template_url=self.elevate_access.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..2ff0e1635725 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -52,7 +58,8 @@ def list_for_resource_group( :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"] @@ -60,35 +67,31 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +104,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -135,7 +140,8 @@ 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"] @@ -143,39 +149,39 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,12 +194,13 @@ async def get_next(next_link=None): 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 ) 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..549f0bc046fa 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -63,33 +69,22 @@ async def get( 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') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +93,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", @@ -110,8 +108,10 @@ def list( :param expand: Specifies whether to expand the values. :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"] @@ -119,32 +119,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -157,12 +154,13 @@ async def get_next(next_link=None): 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 ) 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..ebd6905d450d 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -77,41 +85,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +132,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -150,8 +160,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -159,37 +171,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -202,17 +210,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +245,22 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +271,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -289,8 +292,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 @@ -304,37 +307,27 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - # 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') + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +336,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +363,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +387,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, @@ -425,31 +414,21 @@ async def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +439,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, @@ -487,36 +469,26 @@ async def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +497,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, @@ -549,31 +524,21 @@ async def get_by_id( 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) - # 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 = build_get_by_id_request( + role_assignment_id=role_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +547,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -596,8 +564,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -605,36 +575,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,17 +612,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_scope( self, scope: str, @@ -673,8 +640,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -682,36 +651,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -724,12 +688,13 @@ async def get_next(next_link=None): 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 ) 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..634589c0968d 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,32 +69,22 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +95,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -123,32 +122,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +146,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -184,37 +176,27 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') - # 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') + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +205,11 @@ 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 + + @distributed_trace def list( self, scope: str, @@ -239,8 +224,10 @@ def list( the given scope as well. :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"] @@ -248,36 +235,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -290,17 +272,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, role_definition_id: str, @@ -324,31 +308,21 @@ async def get_by_id( 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) - - # 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 = build_get_by_id_request( + role_definition_id=role_definition_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +331,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..a71e3bdf67b3 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,48 +6,27 @@ # 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 + __all__ = [ 'ClassicAdministrator', 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..2ca2b4415349 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 @@ -15,16 +15,16 @@ 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 +45,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 +68,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 = { @@ -74,6 +86,12 @@ def __init__( 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 +122,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +167,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +180,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 = { @@ -172,6 +194,10 @@ def __init__( error: Optional["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 +205,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 +223,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 +237,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 = { @@ -223,6 +255,12 @@ def __init__( 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 +269,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 +299,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 +322,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 = { @@ -306,6 +356,20 @@ def __init__( operations: Optional[List["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 +382,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 = { @@ -336,6 +400,12 @@ def __init__( 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 +414,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 = { @@ -366,6 +436,14 @@ def __init__( operations: Optional[List["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 +461,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 """ @@ -407,6 +485,11 @@ def __init__( properties: Optional["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 +502,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 = { @@ -437,6 +520,10 @@ def __init__( properties: "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 +531,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 +545,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 +556,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 = { @@ -483,6 +574,12 @@ def __init__( 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 +590,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 +614,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 +629,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 +651,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 +676,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 = { @@ -603,6 +715,18 @@ def __init__( 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 +741,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 +755,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 +766,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 = { @@ -656,6 +784,12 @@ def __init__( 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/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py index ff02d9d6c5f2..abde27b8f3ed 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 @@ -5,23 +5,56 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ClassicAdministratorsOperations(object): """ClassicAdministratorsOperations operations. @@ -45,16 +78,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,34 +97,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +132,13 @@ def get_next(next_link=None): 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 ) 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..6bfacd93f7c8 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 @@ -5,22 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/elevateAccess') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GlobalAdministratorOperations(object): """GlobalAdministratorOperations operations. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def elevate_access( 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 @@ -61,30 +88,24 @@ def elevate_access( 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 - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_elevate_access_request( + template_url=self.elevate_access.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..095b786eaa95 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 @@ -5,23 +5,99 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PermissionsOperations(object): """PermissionsOperations operations. @@ -45,19 +121,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -65,35 +142,31 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +179,28 @@ def get_next(next_link=None): 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 + @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,7 +215,8 @@ 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"] @@ -149,39 +224,39 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,12 +269,13 @@ def get_next(next_link=None): 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 ) 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..5421b0a79d69 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 @@ -5,23 +5,89 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/providerOperations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ProviderOperationsMetadataOperations(object): """ProviderOperationsMetadataOperations operations. @@ -45,13 +111,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,33 +134,22 @@ def get( 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') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,21 +158,25 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. :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"] @@ -125,32 +184,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -163,12 +219,13 @@ def get_next(next_link=None): 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 ) 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..492ad2fa2446 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 @@ -5,23 +5,388 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +410,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -73,8 +438,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -82,41 +449,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,24 +496,25 @@ def get_next(next_link=None): 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 + @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. @@ -156,8 +524,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -165,37 +535,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,24 +574,25 @@ def get_next(next_link=None): 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 + @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. @@ -242,32 +609,22 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +635,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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 +656,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 @@ -312,37 +671,27 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +700,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -376,32 +727,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +751,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -435,31 +778,21 @@ def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +803,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -498,36 +833,26 @@ def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +861,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -561,31 +888,21 @@ def get_by_id( 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) - # 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 = build_get_by_id_request( + role_assignment_id=role_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,14 +911,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -609,8 +928,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -618,36 +939,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -660,24 +976,25 @@ def get_next(next_link=None): 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 + @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. @@ -687,8 +1004,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -696,36 +1015,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -738,12 +1052,13 @@ def get_next(next_link=None): 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 ) 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..2d0995ab7c81 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 @@ -5,23 +5,200 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + scope: str, + role_definition_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-07-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleDefinitionsOperations(object): """RoleDefinitionsOperations operations. @@ -45,13 +222,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,32 +245,22 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +271,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -129,32 +298,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +322,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -191,37 +352,27 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +381,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -247,8 +400,10 @@ def list( the given scope as well. :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"] @@ -256,36 +411,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -298,23 +448,24 @@ def get_next(next_link=None): 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 + @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, @@ -333,31 +484,21 @@ def get_by_id( 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) - - # 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 = build_get_by_id_request( + role_definition_id=role_definition_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +507,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..d9e90278beda 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,89 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import PermissionsOperations, ProviderOperationsMetadataOperations, RoleAssignmentsOperations, RoleDefinitionsOperations + 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 ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from . import models - -class AuthorizationManagementClient(object): +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 """ 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.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: 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..aa586c5b9104 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..c261cde4a7c0 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..bb435aa48aab 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,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from .. import models - - -class AuthorizationManagementClient(object): +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 """ 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.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - 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..1142d433a0b8 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..f83f7ddbae20 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -52,7 +58,8 @@ def list_for_resource_group( :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"] @@ -60,35 +67,31 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +104,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -135,7 +140,8 @@ 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"] @@ -143,39 +149,39 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,12 +194,13 @@ async def get_next(next_link=None): 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 ) 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..ac868fe2a529 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -63,33 +69,22 @@ async def get( 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') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +93,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", @@ -110,8 +108,10 @@ def list( :param expand: Specifies whether to expand the values. :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"] @@ -119,32 +119,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -157,12 +154,13 @@ async def get_next(next_link=None): 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 ) 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..c8cb2d544767 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -77,41 +85,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +132,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -150,8 +160,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -159,37 +171,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -202,17 +210,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +245,22 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +271,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -289,11 +292,12 @@ 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 @@ -304,37 +308,27 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - # 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') + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +337,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +364,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +388,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -422,31 +412,21 @@ async def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_id=role_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +437,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -470,7 +453,8 @@ async def create_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 @@ -481,36 +465,26 @@ async def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +493,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -540,31 +517,21 @@ async def get_by_id( 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) - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +540,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -587,8 +557,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -596,36 +568,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -638,17 +605,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_scope( self, scope: str, @@ -664,8 +633,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -673,36 +644,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -715,12 +681,13 @@ async def get_next(next_link=None): 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 ) 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..ec8c491b8c5e 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,32 +69,22 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +95,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -123,32 +122,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +146,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -184,37 +176,27 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') - # 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') + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +205,11 @@ 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 + + @distributed_trace def list( self, scope: str, @@ -239,8 +224,10 @@ def list( the given scope as well. :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"] @@ -248,36 +235,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -290,17 +272,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -324,31 +308,21 @@ async def get_by_id( 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) - - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +331,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..ec95a80e25b4 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,40 +6,23 @@ # 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 + __all__ = [ 'ErrorAdditionalInfo', 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..19e9f8ca898d 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 @@ -37,6 +37,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +82,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +95,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 = { @@ -105,6 +109,10 @@ def __init__( error: Optional["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 +120,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 +146,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 +166,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 = { @@ -166,6 +184,12 @@ def __init__( 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 +198,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 +232,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 +258,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 = { @@ -254,6 +294,22 @@ def __init__( operations: Optional[List["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 +322,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 = { @@ -285,6 +341,13 @@ def __init__( 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 +356,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 = { @@ -315,6 +379,15 @@ def __init__( operations: Optional[List["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 +405,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 +440,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 +465,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 +493,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 +511,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 +529,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 +543,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 = { @@ -463,6 +561,12 @@ def __init__( 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 +583,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 = { @@ -518,6 +622,18 @@ def __init__( 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 +648,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 +666,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 +680,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 = { @@ -576,6 +698,12 @@ def __init__( 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/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py index 5fcce526eb28..fe6b3a3f3e34 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 @@ -5,23 +5,99 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2018-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PermissionsOperations(object): """PermissionsOperations operations. @@ -45,19 +121,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -65,35 +142,31 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +179,28 @@ def get_next(next_link=None): 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 + @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,7 +215,8 @@ 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"] @@ -149,39 +224,39 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,12 +269,13 @@ def get_next(next_link=None): 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 ) 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..82b7ff431310 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 @@ -5,23 +5,89 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/providerOperations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ProviderOperationsMetadataOperations(object): """ProviderOperationsMetadataOperations operations. @@ -45,13 +111,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,33 +134,22 @@ def get( 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') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,21 +158,25 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. :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"] @@ -125,32 +184,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -163,12 +219,13 @@ def get_next(next_link=None): 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 ) 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..bcbf01dfbabc 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 @@ -5,23 +5,388 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +410,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -73,8 +438,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -82,41 +449,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,24 +496,25 @@ def get_next(next_link=None): 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 + @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. @@ -156,8 +524,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -165,37 +535,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,24 +574,25 @@ def get_next(next_link=None): 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 + @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. @@ -242,32 +609,22 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +635,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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,11 +656,12 @@ 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 @@ -312,37 +672,27 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +701,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -376,32 +728,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +752,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -432,31 +776,21 @@ def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_id=role_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,21 +801,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -492,36 +829,26 @@ def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +857,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -552,31 +881,21 @@ def get_by_id( 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) - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,14 +904,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -600,8 +921,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -609,36 +932,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -651,24 +969,25 @@ def get_next(next_link=None): 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 + @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. @@ -678,8 +997,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -687,36 +1008,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,12 +1045,13 @@ def get_next(next_link=None): 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 ) 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..0a7b17af2510 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 @@ -5,23 +5,200 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + scope: str, + role_definition_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleDefinitionsOperations(object): """RoleDefinitionsOperations operations. @@ -45,13 +222,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,32 +245,22 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +271,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -129,32 +298,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +322,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -191,37 +352,27 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +381,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -247,8 +400,10 @@ def list( the given scope as well. :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"] @@ -256,36 +411,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -298,23 +448,24 @@ def get_next(next_link=None): 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 + @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, @@ -333,31 +484,21 @@ def get_by_id( 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) - - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +507,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..f233c1c25fee 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,110 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.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_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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + 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_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) + + + def _send_request( + self, + request, # type: 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..15bc9fae3db9 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..31b295dc8d9b 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..0fdbebd4461e 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,110 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.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_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.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_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) - - 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..b107f8f25d76 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..02cee2f48103 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, **kwargs: Any @@ -56,31 +61,21 @@ async def get( 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') + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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,8 +84,11 @@ async def get( 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", @@ -99,7 +97,8 @@ async def put( """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 @@ -110,36 +109,26 @@ async def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') - # 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') + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +137,6 @@ async def put( 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/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..c09815005def 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,8 +60,10 @@ 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"] @@ -63,36 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +110,13 @@ async def get_next(next_link=None): 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 ) 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..240bb769e23c 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,8 +60,10 @@ 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"] @@ -63,35 +71,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,17 +108,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -140,33 +146,23 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +171,11 @@ 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 + + @distributed_trace_async async def patch( self, schedule_definition_id: str, @@ -194,7 +193,8 @@ 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 @@ -205,38 +205,28 @@ async def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +235,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 + 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..a1258cac7452 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def stop( self, schedule_definition_id: str, @@ -62,33 +67,23 @@ async def stop( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -96,6 +91,8 @@ async def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + + @distributed_trace_async async def reset_decisions( self, schedule_definition_id: str, @@ -118,33 +115,23 @@ async def reset_decisions( 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) - - # 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 = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -152,6 +139,8 @@ async def reset_decisions( reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + + @distributed_trace_async async def apply_decisions( self, schedule_definition_id: str, @@ -174,33 +163,23 @@ async def apply_decisions( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -208,6 +187,8 @@ async def apply_decisions( apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + + @distributed_trace_async async def send_reminders( self, schedule_definition_id: str, @@ -230,33 +211,23 @@ async def send_reminders( 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) - - # 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 = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -264,6 +235,8 @@ async def send_reminders( send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + + @distributed_trace_async async def accept_recommendations( self, schedule_definition_id: str, @@ -286,35 +259,26 @@ async def accept_recommendations( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..7b92fc481ce5 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -51,8 +57,10 @@ def list( :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"] @@ -60,34 +68,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,17 +103,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -133,32 +138,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +162,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 + 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..6f6818563588 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -51,8 +57,10 @@ def list( :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"] @@ -60,35 +68,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +105,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -134,33 +140,23 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +165,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 + 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..8e1354fd4ea4 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """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"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +98,13 @@ async def get_next(next_link=None): 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 ) 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..028606a37eca 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """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"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +100,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -127,32 +132,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +156,11 @@ 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 + + @distributed_trace_async async def delete_by_id( self, schedule_definition_id: str, @@ -182,32 +180,22 @@ async def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -215,6 +203,8 @@ async def delete_by_id( 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, @@ -226,7 +216,8 @@ async def create_or_update_by_id( :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 @@ -237,37 +228,27 @@ async def create_or_update_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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,8 +257,11 @@ 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 + + @distributed_trace_async async def stop( self, schedule_definition_id: str, @@ -297,35 +281,26 @@ async def stop( 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) - - # 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 = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..8adbb7728621 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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 ) 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..d4fb08e9d3be 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, 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..034e4a3e0de8 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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 AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +19,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The outcome of applying the decision. """ @@ -52,7 +37,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +53,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +68,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -94,14 +79,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 +96,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an accessReview. """ @@ -127,21 +112,21 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type user/servicePrincipal to review """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..b1d1b2062317 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 @@ -30,12 +30,13 @@ class AccessReviewDecision(msrest.serialization.Model): 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. + :ivar 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 + :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", @@ -67,10 +68,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. Possible values include: "user", "servicePrincipal". + :vartype type_properties_target_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ @@ -120,6 +120,15 @@ def __init__( 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. Possible values include: "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 +153,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 = { @@ -162,6 +171,13 @@ def __init__( 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 @@ -176,12 +192,13 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): 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. + :ivar 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 + :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", @@ -211,9 +228,9 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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. + :ivar 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 + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -256,6 +273,15 @@ def __init__( 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. Possible values include: "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 +308,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. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -303,6 +329,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionTarget, self).__init__(**kwargs) self.type = None # type: Optional[str] @@ -319,50 +347,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 + :vartype justification_required_on_approval: bool + :ivar 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 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 + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :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. + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :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 = { @@ -410,6 +438,53 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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 @@ -446,10 +521,10 @@ class AccessReviewInstance(msrest.serialization.Model): "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 +550,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 +568,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 = { @@ -505,6 +586,13 @@ def __init__( 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,8 +603,8 @@ 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_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: "user", "servicePrincipal". :vartype principal_type: str or @@ -538,6 +626,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,21 +646,21 @@ 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 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. 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 + :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 @@ -576,8 +668,8 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): 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: + :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 @@ -587,50 +679,50 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): 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 + :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 + :vartype justification_required_on_approval: bool + :ivar 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 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 + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :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, + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :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 : @@ -716,6 +808,68 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. Possible values include: "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 +907,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 = { @@ -772,6 +926,13 @@ def __init__( 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,21 +943,21 @@ 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 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. 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 + :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 @@ -804,8 +965,8 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): 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: + :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 @@ -815,50 +976,50 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): 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 + :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 + :vartype justification_required_on_approval: bool + :ivar 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 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: + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :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. + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :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. @@ -938,6 +1099,67 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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 +1194,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 + :vartype justification_required_on_approval: bool + :ivar 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 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, + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :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. Possible values + include: "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 = { @@ -1054,6 +1276,53 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. Possible + values include: "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 +1343,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 = { @@ -1088,6 +1357,11 @@ def __init__( error: Optional["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 +1373,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 +1392,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 +1404,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 = { @@ -1152,6 +1430,16 @@ def __init__( 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 +1480,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1202,10 +1492,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 = { @@ -1220,6 +1510,12 @@ def __init__( 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 +1528,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. Possible values include: "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 +1557,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServicePrincipalDecisionTarget, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.principal_id = None @@ -1275,9 +1573,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. Possible values include: "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 +1602,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/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..247f68cb7957 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 @@ -5,22 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewDefaultSettingsOperations(object): """AccessReviewDefaultSettingsOperations operations. @@ -44,11 +118,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -61,31 +135,21 @@ def get( 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 = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,18 +158,21 @@ def get( 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, # 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 @@ -116,36 +183,26 @@ def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') - # 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') + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +211,6 @@ def put( 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/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..02bd2df39e23 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 @@ -5,23 +5,60 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstanceDecisionsOperations(object): """AccessReviewInstanceDecisionsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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,8 +96,10 @@ 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"] @@ -68,36 +107,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +146,13 @@ def get_next(next_link=None): 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 ) 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..efc09e691fe8 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 @@ -5,23 +5,138 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewInstanceMyDecisionsOperations(object): """AccessReviewInstanceMyDecisionsOperations operations. @@ -45,13 +160,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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,8 +174,10 @@ 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"] @@ -68,35 +185,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,25 +222,26 @@ def get_next(next_link=None): 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 + @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. @@ -146,33 +260,23 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +285,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 + + @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,7 +307,8 @@ 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 @@ -212,38 +319,28 @@ def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +349,6 @@ def patch( 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/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..f3fa50197707 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 @@ -5,22 +5,197 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstanceOperations(object): """AccessReviewInstanceOperations operations. @@ -44,13 +219,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def stop( 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. @@ -67,33 +242,23 @@ def stop( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -101,13 +266,14 @@ def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + + @distributed_trace def reset_decisions( 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. @@ -124,33 +290,23 @@ def reset_decisions( 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) - - # 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 = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -158,13 +314,14 @@ def reset_decisions( reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + + @distributed_trace def apply_decisions( 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. @@ -181,33 +338,23 @@ def apply_decisions( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -215,13 +362,14 @@ def apply_decisions( apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + + @distributed_trace def send_reminders( 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. @@ -238,33 +386,23 @@ def send_reminders( 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) - - # 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 = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -272,13 +410,14 @@ def send_reminders( send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + + @distributed_trace def accept_recommendations( 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. @@ -295,35 +434,26 @@ def accept_recommendations( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..62c379348d7b 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 @@ -5,23 +5,89 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstancesAssignedForMyApprovalOperations(object): """AccessReviewInstancesAssignedForMyApprovalOperations operations. @@ -45,19 +111,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -65,34 +133,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,24 +168,25 @@ def get_next(next_link=None): 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 + @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. @@ -139,32 +203,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +227,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 + 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..2c93c6dfe4db 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstancesOperations(object): """AccessReviewInstancesOperations operations. @@ -45,19 +115,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -65,35 +137,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,24 +174,25 @@ def get_next(next_link=None): 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 + @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. @@ -140,33 +209,23 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +234,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 + 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..9aa111420d27 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. @@ -45,16 +72,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,30 +91,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +124,13 @@ def get_next(next_link=None): 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 ) 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..1fe786e16de0 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 @@ -5,23 +5,198 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsOperations(object): """AccessReviewScheduleDefinitionsOperations operations. @@ -45,16 +220,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,34 +239,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,23 +274,24 @@ def get_next(next_link=None): 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 + @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. @@ -133,32 +306,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +330,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 + + @distributed_trace def delete_by_id( 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. @@ -189,32 +354,22 @@ def delete_by_id( 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) - # 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 = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -222,19 +377,21 @@ def delete_by_id( 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 @@ -245,37 +402,27 @@ def create_or_update_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - # 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') + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +431,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 + + @distributed_trace def stop( 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. @@ -306,35 +455,26 @@ def stop( 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) - # 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 = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..7bdcb4fb5ad3 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..c93f08d11195 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,77 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse 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 . 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): +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 """ 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.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: 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..d8041b13b3d4 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..4b4644d299fb 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..ecef3bc7002a 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest 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 .. 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): +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 """ 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.deny_assignments = DenyAssignmentsOperations( - 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..de21c35d6412 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..0690ed8f5504 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -75,8 +81,10 @@ def list_for_resource( assignment name and description properties are returned. :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"] @@ -84,41 +92,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,17 +139,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -164,8 +174,10 @@ def list_for_resource_group( assignment name and description properties are returned. :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"] @@ -173,37 +185,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -216,17 +224,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list( self, filter: Optional[str] = None, @@ -246,8 +256,10 @@ def list( assignment name and description properties are returned. :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"] @@ -255,36 +267,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -297,17 +304,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get( self, scope: str, @@ -330,32 +339,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + deny_assignment_id=deny_assignment_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +363,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, deny_assignment_id: str, @@ -389,31 +391,21 @@ async def get_by_id( 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) - - # 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 = build_get_by_id_request( + deny_assignment_id=deny_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +414,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{denyAssignmentId}'} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -446,8 +441,10 @@ def list_for_scope( assignment name and description properties are returned. :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"] @@ -455,36 +452,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,12 +489,13 @@ async def get_next(next_link=None): 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 ) 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..72781cfd661b 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,24 +6,15 @@ # 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 + __all__ = [ 'DenyAssignment', 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..4c940cb1e6ae 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 @@ -23,25 +23,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 = { @@ -77,6 +78,28 @@ def __init__( 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 +117,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 +141,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 +160,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 = { @@ -145,6 +178,12 @@ def __init__( 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 +192,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 +219,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 +262,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -255,6 +307,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -266,8 +320,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 = { @@ -280,6 +334,10 @@ def __init__( error: Optional["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 +345,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 +371,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/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..66e2f383fa03 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 @@ -5,23 +5,241 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2018-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-07-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + deny_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-07-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + deny_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-07-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-07-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DenyAssignmentsOperations(object): """DenyAssignmentsOperations operations. @@ -45,17 +263,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -80,8 +298,10 @@ def list_for_resource( assignment name and description properties are returned. :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"] @@ -89,41 +309,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,24 +356,25 @@ def get_next(next_link=None): 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 + @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. @@ -170,8 +391,10 @@ def list_for_resource_group( assignment name and description properties are returned. :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"] @@ -179,37 +402,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,23 +441,24 @@ def get_next(next_link=None): 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 + @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 @@ -253,8 +473,10 @@ def list( assignment name and description properties are returned. :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"] @@ -262,36 +484,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,24 +521,25 @@ def get_next(next_link=None): 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 + @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. @@ -338,32 +556,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + deny_assignment_id=deny_assignment_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +580,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -398,31 +608,21 @@ def get_by_id( 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) - - # 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 = build_get_by_id_request( + deny_assignment_id=deny_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +631,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -456,8 +658,10 @@ def list_for_scope( assignment name and description properties are returned. :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"] @@ -465,36 +669,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -507,12 +706,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..140ff02bf767 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,77 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse 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 . 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): +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 """ 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.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: 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..b7e4748497ad 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..0ef90a26d1af 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..24e7ae592a82 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest 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 .. 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): +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 """ 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.role_assignments = RoleAssignmentsOperations( - 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..ec896b61f4b9 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..a1112f8e4297 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -77,41 +85,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +132,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -150,8 +160,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -159,37 +171,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -202,17 +210,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +245,22 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +271,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -289,11 +292,12 @@ 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 @@ -304,37 +308,27 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - # 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') + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +337,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +364,22 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +388,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -422,31 +412,21 @@ async def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_id=role_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +437,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -470,7 +453,8 @@ async def create_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 @@ -481,36 +465,26 @@ async def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +493,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -540,31 +517,21 @@ async def get_by_id( 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) - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +540,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -587,8 +557,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -596,36 +568,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -638,17 +605,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_scope( self, scope: str, @@ -664,8 +633,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -673,36 +644,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -715,12 +681,13 @@ async def get_next(next_link=None): 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 ) 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..870dec87abfb 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,22 +6,14 @@ # 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, 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..12cdb7b790d1 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..5c8244ca163c 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 @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -82,6 +84,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -93,8 +97,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 = { @@ -107,6 +111,10 @@ def __init__( error: Optional["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 +130,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. Possible values include: + "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 = { @@ -162,6 +171,20 @@ 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 principal_type: The principal type of the assigned principal ID. Possible values + include: "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 +201,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. Possible values include: + "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 = { @@ -211,6 +235,19 @@ 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 principal_type: The principal type of the assigned principal ID. Possible values + include: "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 +258,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 +276,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 +290,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 = { @@ -265,6 +308,12 @@ def __init__( 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/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..cfbd7e0cad09 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 @@ -5,23 +5,388 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +410,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -73,8 +438,10 @@ def list_for_resource( assignments at, above or below the scope for the specified principal. :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"] @@ -82,41 +449,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,24 +496,25 @@ def get_next(next_link=None): 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 + @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. @@ -156,8 +524,10 @@ def list_for_resource_group( assignments at, above or below the scope for the specified principal. :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"] @@ -165,37 +535,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,24 +574,25 @@ def get_next(next_link=None): 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 + @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. @@ -242,32 +609,22 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +635,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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,11 +656,12 @@ 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 @@ -312,37 +672,27 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +701,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -376,32 +728,22 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +752,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -432,31 +776,21 @@ def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + role_id=role_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,21 +801,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -492,36 +829,26 @@ def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +857,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -552,31 +881,21 @@ def get_by_id( 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) - # 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 = build_get_by_id_request( + role_id=role_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,14 +904,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -600,8 +921,10 @@ def list( assignments at, above or below the scope for the specified principal. :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"] @@ -609,36 +932,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -651,24 +969,25 @@ def get_next(next_link=None): 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 + @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. @@ -678,8 +997,10 @@ def list_for_scope( assignments at, above or below the scope for the specified principal. :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"] @@ -687,36 +1008,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,12 +1045,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..8f7c0310cee2 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,77 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse 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 . 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): +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 """ 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.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: 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..2a4779277009 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..1b9d016dfad0 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..0b5a6471ca48 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest 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 .. 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): +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 """ 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.role_assignment_metrics = RoleAssignmentMetricsOperations( - 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..a1e070d07130 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..fabdf8e514a8 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_metrics_for_subscription( self, **kwargs: Any @@ -56,31 +61,21 @@ async def get_metrics_for_subscription( 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') + + request = build_get_metrics_for_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.get_metrics_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.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 +84,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 + 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..561f2e98a4c5 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,16 +6,11 @@ # 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 + __all__ = [ 'ErrorAdditionalInfo', 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..ccc19aa4c8a4 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 @@ -37,6 +37,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +82,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +95,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 = { @@ -105,6 +109,10 @@ def __init__( error: Optional["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 +150,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/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..54eec5d776ed 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 @@ -5,22 +5,55 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2019-08-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentMetricsOperations(object): """RoleAssignmentMetricsOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -61,31 +94,21 @@ def get_metrics_for_subscription( 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') + + request = build_get_metrics_for_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.get_metrics_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.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 +117,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 + 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..498de155dacc 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,77 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse 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 . 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): +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 """ 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.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: 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..90f63a4cc752 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..79f0fe32e713 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..72d0b86272e9 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest 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 .. 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): +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 """ 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.role_assignments = RoleAssignmentsOperations( - 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..1451b2f71fd7 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..a7c8b0aca1bf 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -71,8 +77,10 @@ def list_for_resource( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -80,43 +88,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,17 +137,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -158,8 +168,10 @@ def list_for_resource_group( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -167,39 +179,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -212,17 +220,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def delete( self, scope: str, @@ -248,34 +258,23 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +285,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -304,11 +306,12 @@ 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 @@ -319,37 +322,27 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - # 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') + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +351,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -385,34 +381,23 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +406,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -445,33 +433,22 @@ async def delete_by_id( 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') + + request = build_delete_by_id_request( + role_id=role_id, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +459,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -495,7 +475,8 @@ async def create_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 @@ -506,36 +487,26 @@ async def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +515,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -568,33 +542,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + role_id=role_id, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +566,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -620,8 +586,10 @@ def list( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -629,38 +597,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -673,17 +636,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_scope( self, scope: str, @@ -702,8 +667,10 @@ def list_for_scope( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -711,38 +678,33 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -755,12 +717,13 @@ async def get_next(next_link=None): 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 ) 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..870dec87abfb 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,22 +6,14 @@ # 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, 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..12cdb7b790d1 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..484303c996e8 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 @@ -40,6 +40,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -83,6 +85,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -94,8 +98,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 = { @@ -108,6 +112,10 @@ def __init__( error: Optional["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 +131,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. Possible values include: + "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 = { @@ -198,6 +207,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. Possible values + include: "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 +264,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. Possible values include: + "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 = { @@ -274,6 +317,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. Possible values + include: "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 +355,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 +373,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 +387,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 = { @@ -332,6 +405,12 @@ def __init__( 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/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..16d3717f9911 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 @@ -5,23 +5,416 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,18 +438,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -76,8 +469,10 @@ def list_for_resource( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -85,43 +480,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,25 +529,26 @@ def get_next(next_link=None): 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 + @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. @@ -164,8 +560,10 @@ def list_for_resource_group( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -173,39 +571,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -218,25 +612,26 @@ def get_next(next_link=None): 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 + @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. @@ -255,34 +650,23 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +677,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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,11 +698,12 @@ 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 @@ -327,37 +714,27 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,16 +743,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -394,34 +773,23 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,15 +798,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -455,33 +825,22 @@ def delete_by_id( 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') + + request = build_delete_by_id_request( + role_id=role_id, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,21 +851,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -517,36 +879,26 @@ def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +907,17 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -580,33 +934,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + role_id=role_id, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,15 +958,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -633,8 +978,10 @@ def list( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -642,38 +989,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -686,25 +1028,26 @@ def get_next(next_link=None): 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 + @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. @@ -716,8 +1059,10 @@ def list_for_scope( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -725,38 +1070,33 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -769,12 +1109,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..f2c1b43b6070 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,114 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - -class AuthorizationManagementClient(object): +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_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 """ 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.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: 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..f2c98ed5a2f7 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..85dc2ac225a2 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..cf5acb851c4f 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,114 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AuthorizationManagementClient(object): +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_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 """ 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.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - 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..e6c60a7cd48d 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..48cb6d31c314 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def get( self, scope: str, @@ -57,8 +63,10 @@ def get( of type = 'Subscription' or 'ResourceGroup'. :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"] @@ -66,36 +74,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,6 +116,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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..4b6ac6b43868 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, scope: str, @@ -59,8 +65,10 @@ def list_for_scope( user. :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"] @@ -68,36 +76,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,11 +118,13 @@ 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 + @distributed_trace_async async def get( self, scope: str, @@ -143,26 +148,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,4 +171,6 @@ async def get( 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_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..69394e29b016 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, scope: str, @@ -58,11 +64,12 @@ 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 @@ -73,31 +80,21 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -111,8 +108,11 @@ async def create( 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, @@ -136,26 +136,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +159,11 @@ async def get( 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, @@ -190,8 +183,10 @@ def list_for_scope( where the current user is an approver. :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"] @@ -199,36 +194,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -246,11 +236,13 @@ 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 + @distributed_trace_async async def cancel( self, scope: str, @@ -274,26 +266,16 @@ async def cancel( 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) - - # 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 = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -305,3 +287,4 @@ async def cancel( return cls(pipeline_response, None, {}) 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..a243deff8497 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,26 +69,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def get( 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, @@ -115,8 +114,10 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. :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"] @@ -124,36 +125,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -171,6 +167,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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..0e3c257bf8e6 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, @@ -56,8 +62,10 @@ def list_for_subscription( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -65,38 +73,33 @@ def list_for_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +112,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -138,8 +143,10 @@ def list_for_resource_group( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -147,39 +154,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -192,17 +195,19 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -231,8 +236,10 @@ def list_for_resource( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -240,42 +247,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -288,17 +294,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get( self, scope: str, @@ -327,34 +335,23 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +360,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -382,7 +382,8 @@ 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 @@ -393,37 +394,27 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +427,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, scope: str, @@ -466,34 +460,23 @@ async def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +487,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + + @distributed_trace_async async def validate( self, scope: str, @@ -523,7 +509,8 @@ 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 @@ -534,37 +521,27 @@ async def validate( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.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,8 +550,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate'} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -596,8 +576,10 @@ def list_for_scope( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -605,38 +587,33 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -649,17 +626,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, @@ -685,33 +664,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +688,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, @@ -736,7 +707,8 @@ 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 @@ -747,36 +719,26 @@ async def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +751,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, @@ -816,33 +781,22 @@ async def delete_by_id( 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') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +807,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + + @distributed_trace_async async def validate_by_id( self, role_assignment_id: str, @@ -869,7 +826,8 @@ 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 @@ -880,36 +838,26 @@ async def validate_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.validate_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.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 +866,6 @@ async def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..ceab1fca1ffd 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, scope: str, @@ -58,8 +64,10 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. :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"] @@ -67,36 +75,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,11 +117,13 @@ 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 + @distributed_trace_async async def get( self, scope: str, @@ -142,26 +147,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -175,4 +170,6 @@ async def get( 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_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..562f41d4e191 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, scope: str, @@ -62,7 +68,8 @@ 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 @@ -73,31 +80,21 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -111,8 +108,11 @@ async def create( 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, @@ -136,26 +136,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +159,11 @@ async def get( 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, @@ -190,8 +183,10 @@ def list_for_scope( requests where the current user is an approver. :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"] @@ -199,36 +194,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -246,11 +236,13 @@ 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 + @distributed_trace_async async def cancel( self, scope: str, @@ -274,26 +266,16 @@ async def cancel( 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) - - # 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 = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -305,3 +287,4 @@ async def cancel( return cls(pipeline_response, None, {}) 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..60f20c2c65a1 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,26 +69,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def get( 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, @@ -115,8 +114,10 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. :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"] @@ -124,36 +125,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -171,6 +167,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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..2a70395207e5 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,26 +69,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def get( 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, @@ -123,31 +122,21 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -161,8 +150,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + + @distributed_trace_async async def delete( self, scope: str, @@ -185,26 +177,16 @@ async def delete( 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) - - # 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 = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,6 +199,8 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -227,8 +211,10 @@ def list_for_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"] @@ -236,34 +222,29 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -281,6 +262,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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..b7df0bcf65ee 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -64,26 +70,16 @@ async def get( 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') + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,8 +93,11 @@ async def get( 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, @@ -114,7 +113,8 @@ 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 @@ -125,31 +125,21 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -163,8 +153,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, scope: str, @@ -188,26 +181,16 @@ async def delete( 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) - - # 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 = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -220,6 +203,8 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -230,8 +215,10 @@ def list_for_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"] @@ -239,34 +226,29 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,6 +266,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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..9d53c9c66fc3 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, 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..b3ec75ee17c0 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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 ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApprovalMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of rule """ @@ -35,14 +20,14 @@ class ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARALLEL = "Parallel" NO_APPROVAL = "NoApproval" -class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AssignmentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Assignment type of the role assignment schedule """ ACTIVATED = "Activated" ASSIGNED = "Assigned" -class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnablementRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of enable rules """ @@ -50,7 +35,7 @@ class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): JUSTIFICATION = "Justification" TICKETING = "Ticketing" -class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MemberType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Membership type of the role assignment schedule """ @@ -58,13 +43,13 @@ class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DIRECT = "Direct" GROUP = "Group" -class NotificationDeliveryMechanism(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationDeliveryMechanism(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of notification. """ EMAIL = "Email" -class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The notification level. """ @@ -72,7 +57,7 @@ class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CRITICAL = "Critical" ALL = "All" -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The principal type of the assigned principal ID. """ @@ -82,7 +67,7 @@ class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FOREIGN_GROUP = "ForeignGroup" DEVICE = "Device" -class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecipientType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recipient type. """ @@ -90,7 +75,7 @@ class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPROVER = "Approver" ADMIN = "Admin" -class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc """ @@ -104,7 +89,7 @@ class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SELF_EXTEND = "SelfExtend" SELF_RENEW = "SelfRenew" -class RoleManagementPolicyRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleManagementPolicyRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of rule """ @@ -114,7 +99,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the role assignment schedule. """ @@ -141,7 +126,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SCHEDULE_CREATED = "ScheduleCreated" PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the role assignment schedule expiration """ @@ -149,7 +134,7 @@ class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AFTER_DATE_TIME = "AfterDateTime" NO_EXPIRATION = "NoExpiration" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UserType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..042795b2e211 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 @@ -18,18 +18,20 @@ 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", + :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. 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] + :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 = { @@ -50,6 +52,23 @@ def __init__( approval_stages: Optional[List["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. Possible values include: "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 +80,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 = { @@ -98,6 +118,25 @@ def __init__( escalation_approvers: Optional[List["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 +149,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 +169,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 +211,8 @@ def __init__( self, **kwargs ): + """ + """ super(EligibleChildResource, self).__init__(**kwargs) self.id = None self.name = None @@ -173,10 +222,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 = { @@ -191,6 +241,13 @@ def __init__( 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 +278,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -264,6 +323,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -275,8 +336,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 = { @@ -289,6 +350,10 @@ def __init__( error: Optional["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 +361,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 """ @@ -320,6 +385,16 @@ def __init__( principal: Optional["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 +404,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 +430,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 +450,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 +472,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 +489,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 +511,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 +528,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 +554,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 +574,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 """ @@ -488,6 +599,17 @@ def __init__( policy: Optional["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 +621,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 +646,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 +661,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 +683,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 +700,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 +722,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 +757,8 @@ def __init__( self, **kwargs ): + """ + """ super(PolicyProperties, self).__init__(**kwargs) self.scope = None @@ -620,12 +766,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 +788,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 +805,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 +831,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 +861,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. Possible values include: + "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 +886,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 = { @@ -766,6 +931,27 @@ def __init__( 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. Possible values + include: "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 +979,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. Possible values include: + "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 +1004,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 = { @@ -858,6 +1045,27 @@ def __init__( 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. Possible values + include: "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 +1084,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 +1098,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 +1111,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 """ @@ -920,6 +1132,10 @@ def __init__( value: Optional[List["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 +1152,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. Possible values include: + "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 + :vartype linked_role_eligibility_schedule_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Possible values include: "Activated", "Assigned". - :type assignment_type: str or + :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. 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", + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar 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 + :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 """ @@ -1034,6 +1251,56 @@ def __init__( expanded_properties: Optional["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. Possible values + include: "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. Possible values + include: "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. Possible values include: + "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. 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". + :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 +1326,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 +1348,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 +1373,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. Possible values include: + "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. 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 + :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. Possible values include: "Activated", "Assigned". - :type assignment_type: str or + :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. 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 + :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 """ @@ -1199,6 +1475,57 @@ def __init__( expanded_properties: Optional["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. Possible values + include: "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. 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". + :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. Possible values + include: "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. Possible values include: + "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 +1552,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 +1580,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 +1602,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 = { @@ -1282,6 +1621,13 @@ def __init__( 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 +1636,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 = { @@ -1308,6 +1655,13 @@ def __init__( 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,18 +1680,18 @@ 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 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. 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, + :ivar 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 + :vartype 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", @@ -1347,30 +1701,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. @@ -1433,6 +1787,41 @@ def __init__( 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. Possible values include: "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 +1849,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 +1875,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 +1895,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 = { @@ -1515,6 +1914,13 @@ def __init__( 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 +1929,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 """ @@ -1542,6 +1948,13 @@ def __init__( expiration: Optional["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 +1963,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: + :ivar 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 + :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 = { @@ -1573,6 +1986,15 @@ def __init__( duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role assignment schedule expiration. Possible values include: + "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 +2004,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 +2022,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 +2044,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. Possible values include: + "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. 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", + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar 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 + :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 """ @@ -1703,6 +2132,49 @@ def __init__( expanded_properties: Optional["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. Possible values + include: "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. Possible values + include: "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. 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". + :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 +2198,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 +2220,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 +2245,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. Possible values include: + "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. 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: + :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. 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 + :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 """ @@ -1847,6 +2328,46 @@ def __init__( expanded_properties: Optional["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. Possible values + include: "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. 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". + :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. Possible values + include: "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 +2390,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 +2418,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 +2440,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 = { @@ -1926,6 +2459,13 @@ def __init__( 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 +2474,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 = { @@ -1952,6 +2493,13 @@ def __init__( 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,18 +2518,18 @@ 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 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. 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, + :ivar 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 + :vartype 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", @@ -1991,27 +2539,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. @@ -2072,6 +2620,38 @@ def __init__( 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. Possible values include: "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 +2678,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 +2704,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 +2724,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 = { @@ -2153,6 +2743,13 @@ def __init__( 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 +2758,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 """ @@ -2180,6 +2777,13 @@ def __init__( expiration: Optional["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 +2792,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. 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 + :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 = { @@ -2211,6 +2815,15 @@ def __init__( duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role eligibility schedule expiration. Possible values include: + "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 +2833,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 +2851,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 +2873,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: @@ -2312,6 +2931,19 @@ def __init__( rules: Optional[List["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 +2967,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. Possible values include: + "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 """ @@ -2369,6 +3001,13 @@ def __init__( target: Optional["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 +3019,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. Possible values include: + "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 = { @@ -2414,6 +3053,15 @@ def __init__( setting: Optional["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 +3078,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 +3114,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 +3135,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 = { @@ -2498,6 +3154,13 @@ def __init__( 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 +3171,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. Possible values include: + "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 = { @@ -2546,6 +3209,17 @@ def __init__( 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 +3231,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. Possible values include: + "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] """ @@ -2592,6 +3266,16 @@ def __init__( enabled_rules: Optional[List[Union[str, "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 +3286,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. Possible values include: + "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 = { @@ -2640,6 +3324,17 @@ def __init__( 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 +3344,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 = { @@ -2667,6 +3362,13 @@ def __init__( 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 +3379,33 @@ 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. Possible values include: + "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. Possible values include: "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", + :ivar notification_level: The notification level. Possible values include: "None", "Critical", "All". - :type notification_level: str or + :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", + :ivar 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 + :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 = { @@ -2732,6 +3435,29 @@ def __init__( 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. Possible values include: "Email". + :paramtype notification_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism + :keyword notification_level: The notification level. Possible values include: "None", + "Critical", "All". + :paramtype notification_level: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel + :keyword recipient_type: The recipient type. Possible values include: "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. Possible values include: "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 = { @@ -2816,6 +3556,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword user_type: The type of user. Possible values include: "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 """ @@ -2850,6 +3600,11 @@ def __init__( error_info: Optional["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/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..036e667c5288 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 @@ -5,23 +5,60 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EligibleChildResourcesOperations(object): """EligibleChildResourcesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -62,8 +99,10 @@ def get( of type = 'Subscription' or 'ResourceGroup'. :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"] @@ -71,36 +110,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,6 +152,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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..590c5ae67638 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentScheduleInstancesOperations(object): """RoleAssignmentScheduleInstancesOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -64,8 +134,10 @@ def list_for_scope( user. :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"] @@ -73,36 +145,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,18 +187,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 + @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. @@ -149,26 +217,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,4 +240,6 @@ def get( 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_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..8310c8319666 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 @@ -5,23 +5,169 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentScheduleRequestsOperations(object): """RoleAssignmentScheduleRequestsOperations operations. @@ -45,14 +191,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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,11 +209,12 @@ 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 @@ -78,31 +225,21 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -116,15 +253,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -142,26 +281,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -175,15 +304,17 @@ def get( 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, # 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. @@ -197,8 +328,10 @@ def list_for_scope( where the current user is an approver. :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"] @@ -206,36 +339,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -253,18 +381,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 + @distributed_trace def cancel( 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. @@ -282,26 +411,16 @@ def cancel( 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) - - # 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 = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -313,3 +432,4 @@ def cancel( return cls(pipeline_response, None, {}) 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..fc267cf5551b 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentSchedulesOperations(object): """RoleAssignmentSchedulesOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,26 +138,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,15 +161,17 @@ def get( 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, # 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. @@ -121,8 +183,10 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. :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"] @@ -130,36 +194,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +236,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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..cd55604d2441 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 @@ -5,23 +5,496 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_assignment_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_by_id_request( + role_assignment_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,13 +518,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -61,8 +534,10 @@ def list_for_subscription( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -70,38 +545,33 @@ def list_for_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,25 +584,26 @@ def get_next(next_link=None): 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 + @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. @@ -144,8 +615,10 @@ def list_for_resource_group( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -153,39 +626,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,28 +667,29 @@ def get_next(next_link=None): 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 + @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. @@ -238,8 +708,10 @@ def list_for_resource( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -247,42 +719,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -295,25 +766,26 @@ def get_next(next_link=None): 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 + @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: @@ -335,34 +807,23 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +832,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +854,8 @@ 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 @@ -402,37 +866,27 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - # 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') + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +899,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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: @@ -476,34 +932,23 @@ def delete( 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') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +959,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +981,8 @@ 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 @@ -545,37 +993,27 @@ def validate( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_request( + scope=scope, + role_assignment_name=role_assignment_name, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.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 +1022,18 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + 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: @@ -608,8 +1048,10 @@ def list_for_scope( :param tenant_id: Tenant ID for cross-tenant request. :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"] @@ -617,38 +1059,33 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -661,24 +1098,25 @@ def get_next(next_link=None): 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 + @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, @@ -698,33 +1136,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +1160,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +1179,8 @@ 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 @@ -761,36 +1191,26 @@ def create_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +1223,17 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -831,33 +1253,22 @@ def delete_by_id( 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') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +1279,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +1298,8 @@ 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 @@ -896,36 +1310,26 @@ def validate_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_by_id_request( + role_assignment_id=role_assignment_id, + content_type=content_type, + json=_json, + template_url=self.validate_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.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 +1338,6 @@ def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..6a3542c1b53a 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleEligibilityScheduleInstancesOperations(object): """RoleEligibilityScheduleInstancesOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -63,8 +133,10 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. :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"] @@ -72,36 +144,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,18 +186,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 + @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. @@ -148,26 +216,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,4 +239,6 @@ def get( 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_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..f480a55a3b9a 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 @@ -5,23 +5,169 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleEligibilityScheduleRequestsOperations(object): """RoleEligibilityScheduleRequestsOperations operations. @@ -45,14 +191,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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,7 +213,8 @@ 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 @@ -78,31 +225,21 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -116,15 +253,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -142,26 +281,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -175,15 +304,17 @@ def get( 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, # 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. @@ -197,8 +328,10 @@ def list_for_scope( requests where the current user is an approver. :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"] @@ -206,36 +339,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -253,18 +381,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 + @distributed_trace def cancel( 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. @@ -282,26 +411,16 @@ def cancel( 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) - - # 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 = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -313,3 +432,4 @@ def cancel( return cls(pipeline_response, None, {}) 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..9f2b10d8dda3 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleEligibilitySchedulesOperations(object): """RoleEligibilitySchedulesOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,26 +138,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,15 +161,17 @@ def get( 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, # 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. @@ -121,8 +183,10 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. :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"] @@ -130,36 +194,31 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +236,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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..fd1dad65fad2 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + scope: str, + role_management_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleManagementPoliciesOperations(object): """RoleManagementPoliciesOperations operations. @@ -45,13 +187,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,26 +210,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +233,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -129,31 +263,21 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -167,15 +291,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + + @distributed_trace def delete( 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. @@ -192,26 +318,16 @@ def delete( 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) - # 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 = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -224,19 +340,22 @@ def delete( 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"] @@ -244,34 +363,29 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -289,6 +403,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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..509b9cbb04eb 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_management_policy_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleManagementPolicyAssignmentsOperations(object): """RoleManagementPolicyAssignmentsOperations operations. @@ -45,13 +187,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -69,26 +211,16 @@ def get( 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') + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,16 +234,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +254,8 @@ 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 @@ -131,31 +266,21 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response @@ -169,15 +294,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + + @distributed_trace def delete( 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. @@ -195,26 +322,16 @@ def delete( 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) - # 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 = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -227,19 +344,22 @@ def delete( 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"] @@ -247,34 +367,29 @@ def list_for_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - 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, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -292,6 +407,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..3b9690782d72 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,98 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.role_assignment_approval = RoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: 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..adbdc41fdf90 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,18 +6,16 @@ # 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 @@ -33,13 +31,12 @@ class AuthorizationManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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" @@ -62,4 +59,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..88bb67fa95d3 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..e76f009d9387 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,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.role_assignment_approval = RoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - 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..132ae4e78d11 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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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" @@ -58,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/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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..a0622e45f25f 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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 ) 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..c80727d2afa4 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -58,8 +64,10 @@ def list( targeted for. :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"] @@ -67,32 +75,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,17 +110,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -135,31 +142,21 @@ async def get_by_id( 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) - - # 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 = build_get_by_id_request( + approval_id=approval_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +165,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 + 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..bbe0e0bd1579 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -62,32 +67,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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,8 +91,11 @@ 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 + + @distributed_trace_async async def patch( self, approval_id: str, @@ -112,7 +110,8 @@ 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 @@ -123,37 +122,27 @@ async def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - # 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') + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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,8 +151,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + @distributed_trace_async async def put( self, approval_id: str, @@ -178,7 +170,8 @@ 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 @@ -189,37 +182,27 @@ async def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +211,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized + 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..12d4761adf95 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, approval_id: str, @@ -51,7 +56,8 @@ async def list( :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"] @@ -59,31 +65,21 @@ async def list( 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') + + request = build_list_request( + approval_id=approval_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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 +88,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + 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..485fc6ea0108 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, @@ -61,8 +67,10 @@ def list( targeted for. :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"] @@ -70,36 +78,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,17 +115,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -145,32 +150,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + approval_id=approval_id, + scope=scope, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +174,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 + 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..d935917d49ae 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -65,33 +70,23 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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,8 +95,11 @@ 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 + + @distributed_trace_async async def patch( self, approval_id: str, @@ -119,7 +117,8 @@ 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 @@ -130,38 +129,28 @@ async def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - # 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') + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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,8 +159,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + @distributed_trace_async async def put( self, approval_id: str, @@ -189,7 +181,8 @@ 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 @@ -200,38 +193,28 @@ async def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +223,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized + 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..a91ba75a5e68 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, approval_id: str, @@ -54,7 +59,8 @@ 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"] @@ -62,32 +68,22 @@ async def list( 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 = build_list_request( + approval_id=approval_id, + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +92,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + 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..33229e80b925 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,28 +6,17 @@ # 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, 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..4ab4ff550b5b 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,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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 RoleAssignmentApprovalActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class RoleAssignmentApprovalStepReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalStepReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -42,7 +27,7 @@ class RoleAssignmentApprovalStepReviewResult(with_metaclass(_CaseInsensitiveEnum DENY = "Deny" NOT_REVIEWED = "NotReviewed" -class RoleAssignmentApprovalStepStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalStepStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..87ba11aa15dc 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 @@ -17,8 +17,8 @@ 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 = { @@ -31,6 +31,11 @@ def __init__( error: Optional["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 +47,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 +66,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 +78,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 = { @@ -95,6 +104,16 @@ def __init__( 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 +154,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -145,10 +166,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 = { @@ -163,6 +184,12 @@ def __init__( 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 +206,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] """ @@ -203,6 +230,11 @@ def __init__( stages: Optional[List["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 +247,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 """ @@ -236,6 +269,11 @@ def __init__( value: Optional[List["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,8 +290,8 @@ 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 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. Possible values include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", "Escalated". @@ -263,13 +301,13 @@ class RoleAssignmentApprovalStep(msrest.serialization.Model): :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 + :ivar 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 + :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: @@ -319,6 +357,17 @@ def __init__( 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. Possible values include: "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 +389,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 @@ -362,6 +411,11 @@ def __init__( value: Optional[List["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,8 +426,8 @@ 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 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. Possible values include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", "Escalated". @@ -383,13 +437,13 @@ class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): :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 + :ivar 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 + :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: @@ -433,6 +487,17 @@ def __init__( 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. Possible values include: "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/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py index 7e220da70af2..98522293f2f5 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): 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 ) 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..acbaea870fbd 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 @@ -5,23 +5,85 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/roleAssignmentApprovals') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + approval_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentApprovalOperations(object): """RoleAssignmentApprovalOperations operations. @@ -45,12 +107,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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: @@ -63,8 +125,10 @@ def list( targeted for. :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"] @@ -72,32 +136,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,23 +171,24 @@ def get_next(next_link=None): 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 + @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. @@ -141,31 +203,21 @@ def get_by_id( 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) - - # 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 = build_get_by_id_request( + approval_id=approval_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +226,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + 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..60d1172446ff 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 @@ -5,22 +5,142 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + approval_id: str, + stage_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class RoleAssignmentApprovalStepOperations(object): """RoleAssignmentApprovalStepOperations operations. @@ -44,13 +164,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -67,32 +187,22 @@ def get_by_id( 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 = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +211,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 + + @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,7 +230,8 @@ 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 @@ -129,37 +242,27 @@ def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +271,18 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +290,8 @@ 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 @@ -196,37 +302,27 @@ def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +331,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized + 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..f96ba5b6db54 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 @@ -5,22 +5,55 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RoleAssignmentApprovalStepsOperations(object): """RoleAssignmentApprovalStepsOperations operations. @@ -44,19 +77,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -64,31 +98,21 @@ def list( 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') + + request = build_list_request( + approval_id=approval_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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 +121,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + 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..654fba4c3322 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-01-01-preview" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + approval_id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01-preview" + 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ScopeRoleAssignmentApprovalOperations(object): """ScopeRoleAssignmentApprovalOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -66,8 +136,10 @@ def list( targeted for. :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"] @@ -75,36 +147,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,24 +184,25 @@ def get_next(next_link=None): 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 + @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. @@ -151,32 +219,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + approval_id=approval_id, + scope=scope, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +243,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 + 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..b820938b43f2 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 @@ -5,22 +5,148 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + approval_id: str, + stage_id: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ScopeRoleAssignmentApprovalStepOperations(object): """ScopeRoleAssignmentApprovalStepOperations operations. @@ -44,14 +170,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -70,33 +196,23 @@ def get_by_id( 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 = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +221,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 + + @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,7 +243,8 @@ 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 @@ -136,38 +255,28 @@ def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +285,19 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized + 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,7 +307,8 @@ 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 @@ -207,38 +319,28 @@ def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +349,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized + 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..fc6e34aff749 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 @@ -5,22 +5,57 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ScopeRoleAssignmentApprovalStepsOperations(object): """ScopeRoleAssignmentApprovalStepsOperations operations. @@ -44,13 +79,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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,7 +94,8 @@ 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"] @@ -67,32 +103,22 @@ def list( 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') + + request = build_list_request( + approval_id=approval_id, + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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 +127,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + 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..6bee2d262ef1 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..094183e31440 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,110 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.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_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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + 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_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) + + + def _send_request( + self, + request, # type: 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..1af436b87275 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,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AuthorizationManagementClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..7fbd1f456ee5 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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d 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 @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..8c7287907971 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,110 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AuthorizationManagementClient(object): +class AuthorizationManagementClient: """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 """ 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.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_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.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_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) - - 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..db0fc347385a 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..3ddddcbb00c0 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, **kwargs: Any @@ -56,31 +61,21 @@ async def get( 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') + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) response = pipeline_response.http_response if response.status_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,8 +84,11 @@ async def get( 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", @@ -99,7 +97,8 @@ async def put( """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 @@ -110,36 +109,26 @@ async def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') - # 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') + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +137,6 @@ async def put( 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_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..d6b92c9edea5 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -60,8 +66,10 @@ def list( returned. :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"] @@ -69,38 +77,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,12 +118,13 @@ async def get_next(next_link=None): 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 ) 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..da91e771ed1f 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -60,8 +66,10 @@ def list( returned. :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"] @@ -69,37 +77,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,17 +116,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -148,33 +154,23 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +179,11 @@ 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 + + @distributed_trace_async async def patch( self, schedule_definition_id: str, @@ -202,7 +201,8 @@ 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 @@ -213,38 +213,28 @@ async def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +243,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 + 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..ccc251fb97a1 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def stop( self, schedule_definition_id: str, @@ -62,33 +67,23 @@ async def stop( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -96,6 +91,8 @@ async def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + + @distributed_trace_async async def reset_decisions( self, schedule_definition_id: str, @@ -118,33 +115,23 @@ async def reset_decisions( 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) - - # 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 = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -152,6 +139,8 @@ async def reset_decisions( reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + + @distributed_trace_async async def apply_decisions( self, schedule_definition_id: str, @@ -174,33 +163,23 @@ async def apply_decisions( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -208,6 +187,8 @@ async def apply_decisions( apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + + @distributed_trace_async async def send_reminders( self, schedule_definition_id: str, @@ -230,33 +211,23 @@ async def send_reminders( 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) - - # 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 = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -264,6 +235,8 @@ async def send_reminders( send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + + @distributed_trace_async async def accept_recommendations( self, schedule_definition_id: str, @@ -286,35 +259,26 @@ async def accept_recommendations( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..6e2bc70d7345 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -57,8 +63,10 @@ def list( returned. :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"] @@ -66,36 +74,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,17 +111,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -141,32 +146,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +170,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 + 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..598d99e64c46 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -57,8 +63,10 @@ def list( returned. :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"] @@ -66,37 +74,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +113,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -142,33 +148,23 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +173,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 + 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..dae4a63208f5 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -54,8 +60,10 @@ def list( returned. :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"] @@ -63,32 +71,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,12 +106,13 @@ async def get_next(next_link=None): 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 ) 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..25a7d542f212 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -54,8 +60,10 @@ def list( returned. :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"] @@ -63,36 +71,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,17 +108,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -135,32 +140,22 @@ async def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +164,11 @@ 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 + + @distributed_trace_async async def delete_by_id( self, schedule_definition_id: str, @@ -190,32 +188,22 @@ async def delete_by_id( 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) - - # 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 = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -223,6 +211,8 @@ async def delete_by_id( 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, @@ -234,7 +224,8 @@ async def create_or_update_by_id( :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 @@ -245,37 +236,27 @@ async def create_or_update_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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,8 +265,11 @@ 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 + + @distributed_trace_async async def stop( self, schedule_definition_id: str, @@ -305,35 +289,26 @@ async def stop( 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) - - # 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 = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..3536ac4e2582 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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 ) 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..a97906e4ebe9 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, 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..087730f1c7a6 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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 AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +19,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The outcome of applying the decision. """ @@ -52,7 +37,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +53,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +68,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -94,14 +79,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 +96,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an accessReview. """ @@ -127,14 +112,14 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopeAssignmentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopeAssignmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The role assignment state eligible/active to review """ ELIGIBLE = "eligible" ACTIVE = "active" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type user/servicePrincipal to review """ @@ -142,20 +127,20 @@ class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, st GUEST_USER = "guestUser" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of resource """ AZURE_ROLE = "azureRole" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..fa3f8120071e 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 @@ -30,12 +30,13 @@ class AccessReviewDecision(msrest.serialization.Model): 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. + :ivar 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 + :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", @@ -67,19 +68,19 @@ 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 + :ivar type_properties_resource_type: The type of resource.Constant filled by server. Possible values include: "azureRole". - :type type_properties_resource_type: str or + :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", + :ivar 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 + :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 @@ -143,6 +144,15 @@ def __init__( 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. Possible values include: "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 +189,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. Possible values include: "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 +218,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionIdentity, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -217,10 +229,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 = { @@ -235,6 +247,13 @@ def __init__( 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 @@ -249,12 +268,13 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): 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. + :ivar 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 + :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", @@ -284,18 +304,18 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :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 + :ivar type_resource_type: The type of resource.Constant filled by server. Possible values include: "azureRole". - :type type_resource_type: str or + :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. Possible values include: "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 @@ -353,6 +373,15 @@ def __init__( 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. Possible values include: "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 +415,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. Possible values include: + "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 +444,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionResource, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -428,9 +459,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. Possible values include: "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 +488,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.app_id = None @@ -469,9 +502,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. Possible values include: "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 +531,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) self.type = 'user' # type: str self.user_principal_name = None @@ -515,50 +550,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 + :vartype justification_required_on_approval: bool + :ivar 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 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 + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :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. + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :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 = { @@ -606,6 +641,53 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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 @@ -642,10 +724,10 @@ class AccessReviewInstance(msrest.serialization.Model): "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 +753,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 +771,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 = { @@ -701,6 +789,13 @@ def __init__( 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,8 +806,8 @@ 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_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: "user", "servicePrincipal". :vartype principal_type: str or @@ -734,6 +829,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,24 +849,24 @@ 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 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. 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 + :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 @@ -775,8 +874,8 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): 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: + :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 @@ -790,55 +889,55 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): 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 + :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 + :vartype justification_required_on_approval: bool + :ivar 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 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 + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :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, + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :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 : @@ -930,6 +1029,76 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. Possible values include: "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 +1139,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 = { @@ -989,6 +1158,13 @@ def __init__( 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,24 +1175,24 @@ 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 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. 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 + :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 @@ -1024,8 +1200,8 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): 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: + :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 @@ -1039,55 +1215,55 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): 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 + :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 + :vartype justification_required_on_approval: bool + :ivar 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 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: + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :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. + :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. Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :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. @@ -1173,6 +1349,75 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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 +1455,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 + :vartype justification_required_on_approval: bool + :ivar 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 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, + :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. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :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. Possible values + include: "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 = { @@ -1292,6 +1537,53 @@ def __init__( 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. Possible values include: "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. Possible values include: "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. Possible + values include: "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 +1604,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 = { @@ -1326,6 +1618,11 @@ def __init__( error: Optional["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 +1634,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 +1653,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 +1665,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 = { @@ -1390,6 +1691,16 @@ def __init__( 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 +1741,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1440,10 +1753,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 = { @@ -1458,6 +1771,12 @@ def __init__( 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/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..7861253f5f94 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 @@ -5,22 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewDefaultSettingsOperations(object): """AccessReviewDefaultSettingsOperations operations. @@ -44,11 +118,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -61,31 +135,21 @@ def get( 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 = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,18 +158,21 @@ def get( 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, # 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 @@ -116,36 +183,26 @@ def put( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') - # 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') + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +211,6 @@ def put( 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_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..eff4b8445e3b 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 @@ -5,23 +5,64 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstanceDecisionsOperations(object): """AccessReviewInstanceDecisionsOperations operations. @@ -45,14 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -65,8 +106,10 @@ def list( returned. :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"] @@ -74,38 +117,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,12 +158,13 @@ def get_next(next_link=None): 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 ) 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..43610aa0b6ae 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 @@ -5,23 +5,142 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewInstanceMyDecisionsOperations(object): """AccessReviewInstanceMyDecisionsOperations operations. @@ -45,14 +164,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -65,8 +184,10 @@ def list( returned. :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"] @@ -74,37 +195,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,25 +234,26 @@ def get_next(next_link=None): 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 + @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. @@ -154,33 +272,23 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +297,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 + + @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,7 +319,8 @@ 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 @@ -220,38 +331,28 @@ def patch( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +361,6 @@ def patch( 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_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..cc5aa9141441 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 @@ -5,22 +5,197 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstanceOperations(object): """AccessReviewInstanceOperations operations. @@ -44,13 +219,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def stop( 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. @@ -67,33 +242,23 @@ def stop( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -101,13 +266,14 @@ def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + + @distributed_trace def reset_decisions( 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. @@ -124,33 +290,23 @@ def reset_decisions( 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) - - # 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 = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -158,13 +314,14 @@ def reset_decisions( reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + + @distributed_trace def apply_decisions( 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. @@ -181,33 +338,23 @@ def apply_decisions( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -215,13 +362,14 @@ def apply_decisions( apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + + @distributed_trace def send_reminders( 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. @@ -238,33 +386,23 @@ def send_reminders( 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) - - # 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 = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -272,13 +410,14 @@ def send_reminders( send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + + @distributed_trace def accept_recommendations( 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. @@ -295,35 +434,26 @@ def accept_recommendations( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..481e4121714b 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstancesAssignedForMyApprovalOperations(object): """AccessReviewInstancesAssignedForMyApprovalOperations operations. @@ -45,13 +115,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -62,8 +132,10 @@ def list( returned. :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"] @@ -71,36 +143,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,24 +180,25 @@ def get_next(next_link=None): 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 + @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. @@ -147,32 +215,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +239,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 + 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..ef518a2e5a08 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewInstancesOperations(object): """AccessReviewInstancesOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -62,8 +136,10 @@ def list( returned. :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"] @@ -71,37 +147,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,24 +186,25 @@ def get_next(next_link=None): 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 + @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. @@ -148,33 +221,23 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +246,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 + 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..017ae22e1ba1 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 @@ -5,23 +5,54 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. @@ -45,12 +76,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -59,8 +90,10 @@ def list( returned. :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"] @@ -68,32 +101,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +136,13 @@ def get_next(next_link=None): 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 ) 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..ea3083864936 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 @@ -5,23 +5,202 @@ # Code 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsOperations(object): """AccessReviewScheduleDefinitionsOperations operations. @@ -45,12 +224,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -59,8 +238,10 @@ def list( returned. :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"] @@ -68,36 +249,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,23 +286,24 @@ def get_next(next_link=None): 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 + @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. @@ -141,32 +318,22 @@ def get_by_id( 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') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +342,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 + + @distributed_trace def delete_by_id( 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. @@ -197,32 +366,22 @@ def delete_by_id( 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) - # 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 = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -230,19 +389,21 @@ def delete_by_id( 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 @@ -253,37 +414,27 @@ def create_or_update_by_id( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - # 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') + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) response = pipeline_response.http_response if response.status_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 +443,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 + + @distributed_trace def stop( 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. @@ -314,35 +467,26 @@ def stop( 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) - # 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 = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..34d6606e03bb 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +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: + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): 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 ) 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..6bee2d262ef1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..be3c0a21d5d4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +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: + """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 + """ + + 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, # type: 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..7eae3e7b1536 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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): + """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 + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + 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 = "2021-07-01-preview" + 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..8250742dd9e1 --- /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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..e2872ec3f27d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..0aa099e6c41a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +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: + """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 + """ + + 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..fb9325b41d19 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_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 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): + """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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + 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 = "2021-07-01-preview" + 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..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..92ce9ac76bc5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 + +__all__ = [ + 'Operations', + 'AccessReviewScheduleDefinitionsOperations', + 'AccessReviewInstancesOperations', + 'AccessReviewInstanceOperations', + 'AccessReviewInstanceDecisionsOperations', + 'AccessReviewInstanceContactedReviewersOperations', + 'AccessReviewDefaultSettingsOperations', + 'AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations', + 'AccessReviewInstancesAssignedForMyApprovalOperations', + 'AccessReviewInstanceMyDecisionsOperations', + 'TenantLevelAccessReviewInstanceContactedReviewersOperations', +] 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..4ee9f445d4c2 --- /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,142 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..ac66be22cb91 --- /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,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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: + """AccessReviewInstanceContactedReviewersOperations 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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..9e75a6051b3e --- /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,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..a05924b3a731 --- /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,248 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..acc2cd3f5bc9 --- /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,284 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def stop( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to stop an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..a247395b7aff --- /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,175 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..2bfd97be856f --- /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,239 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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: + """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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..1ac49d57ec12 --- /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,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..c9e5c25458fc --- /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,314 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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..9b7c7ff3d15f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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/_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..c7fd08e9f864 --- /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,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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: + """TenantLevelAccessReviewInstanceContactedReviewersOperations 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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.authorization.v2021_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..ab62ea79d1a0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, +) + +__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', +] 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..d3d0204e32a1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The feature- generated recommendation shown to the reviewer. + """ + + APPROVE = "Approve" + DENY = "Deny" + NO_INFO_AVAILABLE = "NoInfoAvailable" + +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type : user/servicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The recurrence type : weekly, monthly, etc. + """ + + WEEKLY = "weekly" + ABSOLUTE_MONTHLY = "absoluteMonthly" + +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The recurrence range type. The possible values are: endDate, noEnd, numbered. + """ + + END_DATE = "endDate" + NO_END = "noEnd" + NUMBERED = "numbered" + +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type : user/servicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The role assignment state eligible/active to review + """ + + ELIGIBLE = "eligible" + ACTIVE = "active" + +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of resource + """ + + AZURE_ROLE = "azureRole" + +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of decision target : User/ServicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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..2b932c8542b8 --- /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, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._authorization_management_client_enums import * + + +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["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. Possible + values include: "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. Possible values include: "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. Possible values include: "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. Possible values include: "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. Possible values include: "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. Possible + values include: "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. Possible values include: "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, "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. Possible values include: "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. Possible values include: "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["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. Possible + values include: "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. Possible values include: "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. Possible values include: "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. + Possible values include: "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. + Possible values include: "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. Possible values + include: "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. Possible values include: "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, "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. Possible values include: "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. Possible values include: + "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. Possible values include: "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. Possible values include: "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. Possible values include: "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. Possible values include: "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. + Possible values include: "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, "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, "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, + 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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. Possible + values include: "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. + Possible values include: "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["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["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["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. Possible + values include: "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. + Possible values include: "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["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["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. Possible values include: + "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. Possible values + include: "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. + Possible values include: "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. Possible values include: "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. Possible values + include: "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. Possible values include: "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. Possible values include: "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. Possible values include: "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. Possible values include: "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["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + instances: Optional[List["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, "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, "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, + 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. Possible values include: "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. Possible values include: "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. Possible values include: "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["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. Possible values + include: "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. + Possible values include: "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. + Possible values include: "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. Possible values + include: "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. Possible values include: "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. Possible values include: "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. + Possible values include: "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. + Possible values include: "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["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + instances: Optional[List["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, "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, "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, + 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. Possible values include: "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. Possible values include: "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. + Possible values include: "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. Possible values include: "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. Possible values include: "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. Possible values + include: "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, "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, "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, + 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. Possible values include: "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. Possible values include: "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. Possible + values include: "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["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["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["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/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..92ce9ac76bc5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 + +__all__ = [ + 'Operations', + 'AccessReviewScheduleDefinitionsOperations', + 'AccessReviewInstancesOperations', + 'AccessReviewInstanceOperations', + 'AccessReviewInstanceDecisionsOperations', + 'AccessReviewInstanceContactedReviewersOperations', + 'AccessReviewDefaultSettingsOperations', + 'AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations', + 'AccessReviewInstancesAssignedForMyApprovalOperations', + 'AccessReviewInstanceMyDecisionsOperations', + 'TenantLevelAccessReviewInstanceContactedReviewersOperations', +] 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..e9f649ae7a4e --- /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,216 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..ab67e46bb244 --- /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,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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class AccessReviewInstanceContactedReviewersOperations(object): + """AccessReviewInstanceContactedReviewersOperations 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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..39c94e86de43 --- /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,171 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..db9980deb2eb --- /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,366 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..5181b1fca918 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def stop( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to stop an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..0e24602ad112 --- /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,244 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class AccessReviewInstancesAssignedForMyApprovalOperations(object): + """AccessReviewInstancesAssignedForMyApprovalOperations 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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..dd0ede10c49f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py @@ -0,0 +1,357 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstancesOperations(object): + """AccessReviewInstancesOperations 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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..58e785716ec6 --- /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,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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..d72dae45c3fb --- /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,492 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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..004393615cfa --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class Operations(object): + """Operations 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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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/_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..a17cd648a6b0 --- /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,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +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: + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class TenantLevelAccessReviewInstanceContactedReviewersOperations(object): + """TenantLevelAccessReviewInstanceContactedReviewersOperations 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_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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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(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