code
stringlengths
501
4.91M
package
stringlengths
2
88
path
stringlengths
11
291
filename
stringlengths
4
197
parsed_code
stringlengths
0
4.91M
quality_prob
float64
0
0.99
learning_prob
float64
0.02
1
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: _models.RoleAssignmentScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: Union[_models.RoleAssignmentScheduleRequest, IO], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a RoleAssignmentScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. Required. :type scope: str :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. Required. :type scope: str :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py
_role_assignment_schedule_requests_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: _models.RoleAssignmentScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: Union[_models.RoleAssignmentScheduleRequest, IO], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a RoleAssignmentScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. Required. :type scope: str :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. Required. :type scope: str :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" }
0.874921
0.0809
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_instances_operations import ( build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilityScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleInstance: """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py
_role_eligibility_schedule_instances_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_instances_operations import ( build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilityScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleInstance: """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" }
0.883211
0.115861
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_for_subscription_request, build_validate_by_id_request, build_validate_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). Required. :type resource_type: str :param resource_name: The resource name. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def validate( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def validate( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def validate( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload async def create_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create_by_id.metadata = {"url": "/{roleAssignmentId}"} @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload async def validate_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def validate_by_id( self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def validate_by_id( self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py
_role_assignments_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_for_subscription_request, build_validate_by_id_request, build_validate_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). Required. :type resource_type: str :param resource_name: The resource name. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def validate( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def validate( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def validate( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload async def create_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create_by_id.metadata = {"url": "/{roleAssignmentId}"} @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload async def validate_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def validate_by_id( self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def validate_by_id( self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<SUB_ID>`/resourcegroups/:code:`<RESOURCE_GROUP>`/providers/Microsoft.Authorization/roleAssignments/:code:`<ROLE_ASSIGNMENT_NAME>`. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"}
0.901621
0.082771
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :vartype code: str :ivar message: A message describing the error, intended to be suitable for display in a user interface. :vartype message: str """ _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :paramtype code: str :keyword message: A message describing the error, intended to be suitable for display in a user interface. :paramtype message: str """ super().__init__(**kwargs) self.code = code self.message = message class EligibleChildResource(_serialization.Model): """Eligible child resource. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The resource scope Id. :vartype id: str :ivar name: The resource name. :vartype name: str :ivar type: The resource type. :vartype type: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None class EligibleChildResourcesListResult(_serialization.Model): """Eligible child resources list operation result. :ivar value: Eligible child resource list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[EligibleChildResource]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.EligibleChildResource"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Eligible child resource list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class ExpandedProperties(_serialization.Model): """ExpandedProperties. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope :ivar role_definition: Details of role definition. :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition :ivar principal: Details of the principal. :vartype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ _attribute_map = { "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, } def __init__( self, *, scope: Optional["_models.ExpandedPropertiesScope"] = None, role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, **kwargs: Any ) -> None: """ :keyword scope: Details of the resource scope. :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope :keyword role_definition: Details of role definition. :paramtype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition :keyword principal: Details of the principal. :paramtype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ super().__init__(**kwargs) self.scope = scope self.role_definition = role_definition self.principal = principal class ExpandedPropertiesPrincipal(_serialization.Model): """Details of the principal. :ivar id: Id of the principal. :vartype id: str :ivar display_name: Display name of the principal. :vartype display_name: str :ivar email: Email id of the principal. :vartype email: str :ivar type: Type of the principal. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "email": {"key": "email", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, email: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the principal. :paramtype id: str :keyword display_name: Display name of the principal. :paramtype display_name: str :keyword email: Email id of the principal. :paramtype email: str :keyword type: Type of the principal. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.email = email self.type = type class ExpandedPropertiesRoleDefinition(_serialization.Model): """Details of role definition. :ivar id: Id of the role definition. :vartype id: str :ivar display_name: Display name of the role definition. :vartype display_name: str :ivar type: Type of the role definition. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the role definition. :paramtype id: str :keyword display_name: Display name of the role definition. :paramtype display_name: str :keyword type: Type of the role definition. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class ExpandedPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class Permission(_serialization.Model): """Role definition permissions. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class PolicyAssignmentProperties(_serialization.Model): """PolicyAssignmentProperties. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope :ivar role_definition: Details of role definition. :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition :ivar policy: Details of the policy. :vartype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ _attribute_map = { "scope": {"key": "scope", "type": "PolicyAssignmentPropertiesScope"}, "role_definition": {"key": "roleDefinition", "type": "PolicyAssignmentPropertiesRoleDefinition"}, "policy": {"key": "policy", "type": "PolicyAssignmentPropertiesPolicy"}, } def __init__( self, *, scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, **kwargs: Any ) -> None: """ :keyword scope: Details of the resource scope. :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope :keyword role_definition: Details of role definition. :paramtype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition :keyword policy: Details of the policy. :paramtype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ super().__init__(**kwargs) self.scope = scope self.role_definition = role_definition self.policy = policy class PolicyAssignmentPropertiesPolicy(_serialization.Model): """Details of the policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Id of the policy. :vartype id: str :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal :ivar last_modified_date_time: The last modified date time. :vartype last_modified_date_time: ~datetime.datetime """ _validation = { "last_modified_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "last_modified_by": {"key": "lastModifiedBy", "type": "Principal"}, "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin last_modified_date_time: Optional[datetime.datetime] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the policy. :paramtype id: str :keyword last_modified_date_time: The last modified date time. :paramtype last_modified_date_time: ~datetime.datetime """ super().__init__(**kwargs) self.id = id self.last_modified_by = None self.last_modified_date_time = last_modified_date_time class PolicyAssignmentPropertiesRoleDefinition(_serialization.Model): """Details of role definition. :ivar id: Id of the role definition. :vartype id: str :ivar display_name: Display name of the role definition. :vartype display_name: str :ivar type: Type of the role definition. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the role definition. :paramtype id: str :keyword display_name: Display name of the role definition. :paramtype display_name: str :keyword type: Type of the role definition. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class PolicyAssignmentPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class PolicyProperties(_serialization.Model): """PolicyProperties. Variables are only populated by the server, and will be ignored when sending a request. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyPropertiesScope """ _validation = { "scope": {"readonly": True}, } _attribute_map = { "scope": {"key": "scope", "type": "PolicyPropertiesScope"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.scope = None class PolicyPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment create parameters. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "scope": {"readonly": True}, "role_definition_id": {"required": True}, "principal_id": {"required": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentSchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignment schedule. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule Id. :vartype id: str :ivar name: The role assignment schedule name. :vartype name: str :ivar type: The role assignment schedule type. :vartype type: str :ivar scope: The role assignment schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule. :vartype role_assignment_schedule_request_id: str :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. :vartype linked_role_eligibility_schedule_id: str :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar status: The status of the role assignment schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: Start DateTime when role assignment schedule. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: End DateTime when role assignment schedule. :vartype end_date_time: ~datetime.datetime :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule was created. :vartype created_on: ~datetime.datetime :ivar updated_on: DateTime when role assignment schedule was modified. :vartype updated_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_assignment_schedule_request_id": {"key": "properties.roleAssignmentScheduleRequestId", "type": "str"}, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "assignment_type": {"key": "properties.assignmentType", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_assignment_schedule_request_id: Optional[str] = None, linked_role_eligibility_schedule_id: Optional[str] = None, assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule. :paramtype role_assignment_schedule_request_id: str :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. :paramtype linked_role_eligibility_schedule_id: str :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :keyword member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword status: The status of the role assignment schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: Start DateTime when role assignment schedule. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: End DateTime when role assignment schedule. :paramtype end_date_time: ~datetime.datetime :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role assignment schedule was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: DateTime when role assignment schedule was modified. :paramtype updated_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_assignment_schedule_request_id = role_assignment_schedule_request_id self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.assignment_type = assignment_type self.member_type = member_type self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.expanded_properties = expanded_properties class RoleAssignmentScheduleFilter(_serialization.Model): """Role assignment schedule filter. :ivar principal_id: Returns role assignment schedule of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment schedule of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role assignment schedule instances of the specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment schedule of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment schedule of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role assignment schedule instances of the specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status class RoleAssignmentScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Information about current or upcoming role assignment schedule instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule instance ID. :vartype id: str :ivar name: The role assignment schedule instance name. :vartype name: str :ivar type: The role assignment schedule instance type. :vartype type: str :ivar scope: The role assignment schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_assignment_schedule_id: Id of the master role assignment schedule. :vartype role_assignment_schedule_id: str :ivar origin_role_assignment_id: Role Assignment Id in external system. :vartype origin_role_assignment_id: str :ivar status: The status of the role assignment schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: The startDateTime of the role assignment schedule instance. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The endDateTime of the role assignment schedule instance. :vartype end_date_time: ~datetime.datetime :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. :vartype linked_role_eligibility_schedule_id: str :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to this roleAssignmentScheduleInstance. :vartype linked_role_eligibility_schedule_instance_id: str :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule was created. :vartype created_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_assignment_schedule_id": {"key": "properties.roleAssignmentScheduleId", "type": "str"}, "origin_role_assignment_id": {"key": "properties.originRoleAssignmentId", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "linked_role_eligibility_schedule_instance_id": { "key": "properties.linkedRoleEligibilityScheduleInstanceId", "type": "str", }, "assignment_type": {"key": "properties.assignmentType", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_assignment_schedule_id: Optional[str] = None, origin_role_assignment_id: Optional[str] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, linked_role_eligibility_schedule_id: Optional[str] = None, linked_role_eligibility_schedule_instance_id: Optional[str] = None, assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_assignment_schedule_id: Id of the master role assignment schedule. :paramtype role_assignment_schedule_id: str :keyword origin_role_assignment_id: Role Assignment Id in external system. :paramtype origin_role_assignment_id: str :keyword status: The status of the role assignment schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: The startDateTime of the role assignment schedule instance. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The endDateTime of the role assignment schedule instance. :paramtype end_date_time: ~datetime.datetime :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. :paramtype linked_role_eligibility_schedule_id: str :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to this roleAssignmentScheduleInstance. :paramtype linked_role_eligibility_schedule_instance_id: str :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :keyword member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role assignment schedule was created. :paramtype created_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_assignment_schedule_id = role_assignment_schedule_id self.origin_role_assignment_id = origin_role_assignment_id self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id self.assignment_type = assignment_type self.member_type = member_type self.condition = condition self.condition_version = condition_version self.created_on = created_on self.expanded_properties = expanded_properties class RoleAssignmentScheduleInstanceFilter(_serialization.Model): """Role assignment schedule instance filter. :ivar principal_id: Returns role assignment schedule instances of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment schedule instances of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role assignment schedule instances of the specific status. :vartype status: str :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a specific role assignment schedule. :vartype role_assignment_schedule_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, "role_assignment_schedule_id": {"key": "roleAssignmentScheduleId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, role_assignment_schedule_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment schedule instances of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment schedule instances of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role assignment schedule instances of the specific status. :paramtype status: str :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a specific role assignment schedule. :paramtype role_assignment_schedule_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status self.role_assignment_schedule_id = role_assignment_schedule_id class RoleAssignmentScheduleInstanceListResult(_serialization.Model): """Role assignment schedule instance list operation result. :ivar value: Role assignment schedule instance list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentScheduleInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule instance list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleListResult(_serialization.Model): """Role assignment schedule list operation result. :ivar value: Role assignment schedule list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentSchedule]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentSchedule"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignment schedule request. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule request ID. :vartype id: str :ivar name: The role assignment schedule request name. :vartype name: str :ivar type: The role assignment schedule request type. :vartype type: str :ivar scope: The role assignment schedule request scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role assignment schedule request. :vartype approval_id: str :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role assignment schedule id being updated. :vartype target_role_assignment_schedule_id: str :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id being updated. :vartype target_role_assignment_schedule_instance_id: str :ivar schedule_info: Schedule info of the role assignment schedule. :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. :vartype linked_role_eligibility_schedule_id: str :ivar justification: Justification for the role assignment. :vartype justification: str :ivar ticket_info: Ticket Info of the role assignment. :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. :vartype requestor_id: str :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "principal_type": {"readonly": True}, "status": {"readonly": True}, "approval_id": {"readonly": True}, "created_on": {"readonly": True}, "requestor_id": {"readonly": True}, "expanded_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "request_type": {"key": "properties.requestType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "approval_id": {"key": "properties.approvalId", "type": "str"}, "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, "target_role_assignment_schedule_instance_id": { "key": "properties.targetRoleAssignmentScheduleInstanceId", "type": "str", }, "schedule_info": { "key": "properties.scheduleInfo", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", }, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "requestor_id": {"key": "properties.requestorId", "type": "str"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, request_type: Optional[Union[str, "_models.RequestType"]] = None, target_role_assignment_schedule_id: Optional[str] = None, target_role_assignment_schedule_instance_id: Optional[str] = None, schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, linked_role_eligibility_schedule_id: Optional[str] = None, justification: Optional[str] = None, ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the role assignment schedule id being updated. :paramtype target_role_assignment_schedule_id: str :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id being updated. :paramtype target_role_assignment_schedule_instance_id: str :keyword schedule_info: Schedule info of the role assignment schedule. :paramtype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. :paramtype linked_role_eligibility_schedule_id: str :keyword justification: Justification for the role assignment. :paramtype justification: str :keyword ticket_info: Ticket Info of the role assignment. :paramtype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = None self.request_type = request_type self.status = None self.approval_id = None self.target_role_assignment_schedule_id = target_role_assignment_schedule_id self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id self.schedule_info = schedule_info self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.justification = justification self.ticket_info = ticket_info self.condition = condition self.condition_version = condition_version self.created_on = None self.requestor_id = None self.expanded_properties = None class RoleAssignmentScheduleRequestFilter(_serialization.Model): """Role assignment schedule request filter. :ivar principal_id: Returns role assignment requests of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment requests of the specific role definition. :vartype role_definition_id: str :ivar requestor_id: Returns role assignment requests created by specific principal. :vartype requestor_id: str :ivar status: Returns role assignment requests of specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "requestor_id": {"key": "requestorId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, requestor_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment requests of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment requests of the specific role definition. :paramtype role_definition_id: str :keyword requestor_id: Returns role assignment requests created by specific principal. :paramtype requestor_id: str :keyword status: Returns role assignment requests of specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.requestor_id = requestor_id self.status = status class RoleAssignmentScheduleRequestListResult(_serialization.Model): """Role assignment schedule request list operation result. :ivar value: Role assignment schedule request list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule request list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): """Schedule info of the role assignment schedule. :ivar start_date_time: Start DateTime of the role assignment schedule. :vartype start_date_time: ~datetime.datetime :ivar expiration: Expiration of the role assignment schedule. :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration """ _attribute_map = { "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: Start DateTime of the role assignment schedule. :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role assignment schedule. :paramtype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): """Expiration of the role assignment schedule. :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :ivar end_date_time: End DateTime of the role assignment schedule. :vartype end_date_time: ~datetime.datetime :ivar duration: Duration of the role assignment schedule in TimeSpan. :vartype duration: str """ _attribute_map = { "type": {"key": "type", "type": "str"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "duration": {"key": "duration", "type": "str"}, } def __init__( self, *, type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :keyword end_date_time: End DateTime of the role assignment schedule. :paramtype end_date_time: ~datetime.datetime :keyword duration: Duration of the role assignment schedule in TimeSpan. :paramtype duration: str """ super().__init__(**kwargs) self.type = type self.end_date_time = end_date_time self.duration = duration class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): """Ticket Info of the role assignment. :ivar ticket_number: Ticket number for the role assignment. :vartype ticket_number: str :ivar ticket_system: Ticket system name for the role assignment. :vartype ticket_system: str """ _attribute_map = { "ticket_number": {"key": "ticketNumber", "type": "str"}, "ticket_system": {"key": "ticketSystem", "type": "str"}, } def __init__( self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword ticket_number: Ticket number for the role assignment. :paramtype ticket_number: str :keyword ticket_system: Ticket system name for the role assignment. :paramtype ticket_system: str """ super().__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system class RoleEligibilitySchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role eligibility schedule. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule Id. :vartype id: str :ivar name: The role eligibility schedule name. :vartype name: str :ivar type: The role eligibility schedule type. :vartype type: str :ivar scope: The role eligibility schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule. :vartype role_eligibility_schedule_request_id: str :ivar member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar status: The status of the role eligibility schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: Start DateTime when role eligibility schedule. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: End DateTime when role eligibility schedule. :vartype end_date_time: ~datetime.datetime :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule was created. :vartype created_on: ~datetime.datetime :ivar updated_on: DateTime when role eligibility schedule was modified. :vartype updated_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_eligibility_schedule_request_id": {"key": "properties.roleEligibilityScheduleRequestId", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_request_id: Optional[str] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role eligibility schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule. :paramtype role_eligibility_schedule_request_id: str :keyword member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword status: The status of the role eligibility schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: Start DateTime when role eligibility schedule. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: End DateTime when role eligibility schedule. :paramtype end_date_time: ~datetime.datetime :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role eligibility schedule was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: DateTime when role eligibility schedule was modified. :paramtype updated_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id self.member_type = member_type self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.expanded_properties = expanded_properties class RoleEligibilityScheduleFilter(_serialization.Model): """Role eligibility schedule filter. :ivar principal_id: Returns role eligibility schedule of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role eligibility schedule of the specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility schedule of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role eligibility schedule of the specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status class RoleEligibilityScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Information about current or upcoming role eligibility schedule instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule instance ID. :vartype id: str :ivar name: The role eligibility schedule instance name. :vartype name: str :ivar type: The role eligibility schedule instance type. :vartype type: str :ivar scope: The role eligibility schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. :vartype role_eligibility_schedule_id: str :ivar status: The status of the role eligibility schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: The startDateTime of the role eligibility schedule instance. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The endDateTime of the role eligibility schedule instance. :vartype end_date_time: ~datetime.datetime :ivar member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule was created. :vartype created_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_eligibility_schedule_id": {"key": "properties.roleEligibilityScheduleId", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "member_type": {"key": "properties.memberType", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_id: Optional[str] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role eligibility schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. :paramtype role_eligibility_schedule_id: str :keyword status: The status of the role eligibility schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: The startDateTime of the role eligibility schedule instance. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The endDateTime of the role eligibility schedule instance. :paramtype end_date_time: ~datetime.datetime :keyword member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role eligibility schedule was created. :paramtype created_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_eligibility_schedule_id = role_eligibility_schedule_id self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.member_type = member_type self.condition = condition self.condition_version = condition_version self.created_on = created_on self.expanded_properties = expanded_properties class RoleEligibilityScheduleInstanceFilter(_serialization.Model): """Role eligibility schedule instance filter. :ivar principal_id: Returns role eligibility schedule instances of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility schedule instances of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role eligibility schedule instances of the specific status. :vartype status: str :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a specific role eligibility schedule. :vartype role_eligibility_schedule_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, "role_eligibility_schedule_id": {"key": "roleEligibilityScheduleId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, role_eligibility_schedule_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility schedule instances of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility schedule instances of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role eligibility schedule instances of the specific status. :paramtype status: str :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a specific role eligibility schedule. :paramtype role_eligibility_schedule_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status self.role_eligibility_schedule_id = role_eligibility_schedule_id class RoleEligibilityScheduleInstanceListResult(_serialization.Model): """Role eligibility schedule instance list operation result. :ivar value: Role eligibility schedule instance list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilityScheduleInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role eligibility schedule instance list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleListResult(_serialization.Model): """role eligibility schedule list operation result. :ivar value: role eligibility schedule list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilitySchedule]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilitySchedule"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: role eligibility schedule list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Eligibility schedule request. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule request ID. :vartype id: str :ivar name: The role eligibility schedule request name. :vartype name: str :ivar type: The role eligibility schedule request type. :vartype type: str :ivar scope: The role eligibility schedule request scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role eligibility schedule request. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role eligibility schedule request. :vartype approval_id: str :ivar schedule_info: Schedule info of the role eligibility schedule. :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. :vartype target_role_eligibility_schedule_id: str :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. :vartype target_role_eligibility_schedule_instance_id: str :ivar justification: Justification for the role eligibility. :vartype justification: str :ivar ticket_info: Ticket Info of the role eligibility. :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. :vartype requestor_id: str :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "principal_type": {"readonly": True}, "status": {"readonly": True}, "approval_id": {"readonly": True}, "created_on": {"readonly": True}, "requestor_id": {"readonly": True}, "expanded_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "request_type": {"key": "properties.requestType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "approval_id": {"key": "properties.approvalId", "type": "str"}, "schedule_info": { "key": "properties.scheduleInfo", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", }, "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, "target_role_eligibility_schedule_instance_id": { "key": "properties.targetRoleEligibilityScheduleInstanceId", "type": "str", }, "justification": {"key": "properties.justification", "type": "str"}, "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "requestor_id": {"key": "properties.requestorId", "type": "str"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, request_type: Optional[Union[str, "_models.RequestType"]] = None, schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, target_role_eligibility_schedule_id: Optional[str] = None, target_role_eligibility_schedule_instance_id: Optional[str] = None, justification: Optional[str] = None, ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :keyword schedule_info: Schedule info of the role eligibility schedule. :paramtype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. :paramtype target_role_eligibility_schedule_id: str :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. :paramtype target_role_eligibility_schedule_instance_id: str :keyword justification: Justification for the role eligibility. :paramtype justification: str :keyword ticket_info: Ticket Info of the role eligibility. :paramtype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = None self.request_type = request_type self.status = None self.approval_id = None self.schedule_info = schedule_info self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id self.justification = justification self.ticket_info = ticket_info self.condition = condition self.condition_version = condition_version self.created_on = None self.requestor_id = None self.expanded_properties = None class RoleEligibilityScheduleRequestFilter(_serialization.Model): """Role eligibility schedule request filter. :ivar principal_id: Returns role eligibility requests of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility requests of the specific role definition. :vartype role_definition_id: str :ivar requestor_id: Returns role eligibility requests created by specific principal. :vartype requestor_id: str :ivar status: Returns role eligibility requests of specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "requestor_id": {"key": "requestorId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, requestor_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility requests of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility requests of the specific role definition. :paramtype role_definition_id: str :keyword requestor_id: Returns role eligibility requests created by specific principal. :paramtype requestor_id: str :keyword status: Returns role eligibility requests of specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.requestor_id = requestor_id self.status = status class RoleEligibilityScheduleRequestListResult(_serialization.Model): """Role eligibility schedule request list operation result. :ivar value: Role eligibility schedule request list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role eligibility schedule request list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): """Schedule info of the role eligibility schedule. :ivar start_date_time: Start DateTime of the role eligibility schedule. :vartype start_date_time: ~datetime.datetime :ivar expiration: Expiration of the role eligibility schedule. :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration """ _attribute_map = { "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: Start DateTime of the role eligibility schedule. :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role eligibility schedule. :paramtype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): """Expiration of the role eligibility schedule. :ivar type: Type of the role eligibility schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :ivar end_date_time: End DateTime of the role eligibility schedule. :vartype end_date_time: ~datetime.datetime :ivar duration: Duration of the role eligibility schedule in TimeSpan. :vartype duration: str """ _attribute_map = { "type": {"key": "type", "type": "str"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "duration": {"key": "duration", "type": "str"}, } def __init__( self, *, type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword type: Type of the role eligibility schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :keyword end_date_time: End DateTime of the role eligibility schedule. :paramtype end_date_time: ~datetime.datetime :keyword duration: Duration of the role eligibility schedule in TimeSpan. :paramtype duration: str """ super().__init__(**kwargs) self.type = type self.end_date_time = end_date_time self.duration = duration class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): """Ticket Info of the role eligibility. :ivar ticket_number: Ticket number for the role eligibility. :vartype ticket_number: str :ivar ticket_system: Ticket system name for the role eligibility. :vartype ticket_system: str """ _attribute_map = { "ticket_number": {"key": "ticketNumber", "type": "str"}, "ticket_system": {"key": "ticketSystem", "type": "str"}, } def __init__( self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword ticket_number: Ticket number for the role eligibility. :paramtype ticket_number: str :keyword ticket_system: Ticket system name for the role eligibility. :paramtype ticket_system: str """ super().__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system class RoleManagementPolicy(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role management policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role management policy Id. :vartype id: str :ivar name: The role management policy name. :vartype name: str :ivar type: The role management policy type. :vartype type: str :ivar scope: The role management policy scope. :vartype scope: str :ivar display_name: The role management policy display name. :vartype display_name: str :ivar description: The role management policy description. :vartype description: str :ivar is_organization_default: The role management policy is default policy. :vartype is_organization_default: bool :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal :ivar last_modified_date_time: The last modified date time. :vartype last_modified_date_time: ~datetime.datetime :ivar rules: The rule applied to the policy. :vartype rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] :ivar effective_rules: The readonly computed rule applied to the policy. :vartype effective_rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] :ivar policy_properties: Additional properties of scope. :vartype policy_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "last_modified_by": {"readonly": True}, "last_modified_date_time": {"readonly": True}, "effective_rules": {"readonly": True}, "policy_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "is_organization_default": {"key": "properties.isOrganizationDefault", "type": "bool"}, "last_modified_by": {"key": "properties.lastModifiedBy", "type": "Principal"}, "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, "rules": {"key": "properties.rules", "type": "[RoleManagementPolicyRule]"}, "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, "policy_properties": {"key": "properties.policyProperties", "type": "PolicyProperties"}, } def __init__( self, *, scope: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, is_organization_default: Optional[bool] = None, rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, **kwargs: Any ) -> None: """ :keyword scope: The role management policy scope. :paramtype scope: str :keyword display_name: The role management policy display name. :paramtype display_name: str :keyword description: The role management policy description. :paramtype description: str :keyword is_organization_default: The role management policy is default policy. :paramtype is_organization_default: bool :keyword rules: The rule applied to the policy. :paramtype rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.display_name = display_name self.description = description self.is_organization_default = is_organization_default self.last_modified_by = None self.last_modified_date_time = None self.rules = rules self.effective_rules = None self.policy_properties = None class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAssignment(_serialization.Model): """Role management policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role management policy Id. :vartype id: str :ivar name: The role management policy name. :vartype name: str :ivar type: The role management policy type. :vartype type: str :ivar scope: The role management policy scope. :vartype scope: str :ivar role_definition_id: The role definition of management policy assignment. :vartype role_definition_id: str :ivar policy_id: The policy id role management policy assignment. :vartype policy_id: str :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. :vartype policy_assignment_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "policy_assignment_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "policy_id": {"key": "properties.policyId", "type": "str"}, "policy_assignment_properties": { "key": "properties.policyAssignmentProperties", "type": "PolicyAssignmentProperties", }, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, policy_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword scope: The role management policy scope. :paramtype scope: str :keyword role_definition_id: The role definition of management policy assignment. :paramtype role_definition_id: str :keyword policy_id: The policy id role management policy assignment. :paramtype policy_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.policy_id = policy_id self.policy_assignment_properties = None class RoleManagementPolicyAssignmentListResult(_serialization.Model): """Role management policy assignment list operation result. :ivar value: Role management policy assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleManagementPolicyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role management policy assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyListResult(_serialization.Model): """Role management policy list operation result. :ivar value: Role management policy list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleManagementPolicy]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleManagementPolicy"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role management policy list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description class ValidationResponse(_serialization.Model): """Validation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool :ivar error_info: Failed validation result details. :vartype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ _validation = { "is_valid": {"readonly": True}, } _attribute_map = { "is_valid": {"key": "isValid", "type": "bool"}, "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, } def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: """ :keyword error_info: Failed validation result details. :paramtype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ super().__init__(**kwargs) self.is_valid = None self.error_info = error_info class ValidationResponseErrorInfo(_serialization.Model): """Failed validation result details. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Error code indicating why validation failed. :vartype code: str :ivar message: Message indicating why validation failed. :vartype message: str """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py
_models_py3.py
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :vartype code: str :ivar message: A message describing the error, intended to be suitable for display in a user interface. :vartype message: str """ _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :paramtype code: str :keyword message: A message describing the error, intended to be suitable for display in a user interface. :paramtype message: str """ super().__init__(**kwargs) self.code = code self.message = message class EligibleChildResource(_serialization.Model): """Eligible child resource. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The resource scope Id. :vartype id: str :ivar name: The resource name. :vartype name: str :ivar type: The resource type. :vartype type: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None class EligibleChildResourcesListResult(_serialization.Model): """Eligible child resources list operation result. :ivar value: Eligible child resource list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[EligibleChildResource]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.EligibleChildResource"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Eligible child resource list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class ExpandedProperties(_serialization.Model): """ExpandedProperties. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope :ivar role_definition: Details of role definition. :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition :ivar principal: Details of the principal. :vartype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ _attribute_map = { "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, } def __init__( self, *, scope: Optional["_models.ExpandedPropertiesScope"] = None, role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, **kwargs: Any ) -> None: """ :keyword scope: Details of the resource scope. :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope :keyword role_definition: Details of role definition. :paramtype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition :keyword principal: Details of the principal. :paramtype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ super().__init__(**kwargs) self.scope = scope self.role_definition = role_definition self.principal = principal class ExpandedPropertiesPrincipal(_serialization.Model): """Details of the principal. :ivar id: Id of the principal. :vartype id: str :ivar display_name: Display name of the principal. :vartype display_name: str :ivar email: Email id of the principal. :vartype email: str :ivar type: Type of the principal. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "email": {"key": "email", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, email: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the principal. :paramtype id: str :keyword display_name: Display name of the principal. :paramtype display_name: str :keyword email: Email id of the principal. :paramtype email: str :keyword type: Type of the principal. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.email = email self.type = type class ExpandedPropertiesRoleDefinition(_serialization.Model): """Details of role definition. :ivar id: Id of the role definition. :vartype id: str :ivar display_name: Display name of the role definition. :vartype display_name: str :ivar type: Type of the role definition. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the role definition. :paramtype id: str :keyword display_name: Display name of the role definition. :paramtype display_name: str :keyword type: Type of the role definition. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class ExpandedPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class Permission(_serialization.Model): """Role definition permissions. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class PolicyAssignmentProperties(_serialization.Model): """PolicyAssignmentProperties. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope :ivar role_definition: Details of role definition. :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition :ivar policy: Details of the policy. :vartype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ _attribute_map = { "scope": {"key": "scope", "type": "PolicyAssignmentPropertiesScope"}, "role_definition": {"key": "roleDefinition", "type": "PolicyAssignmentPropertiesRoleDefinition"}, "policy": {"key": "policy", "type": "PolicyAssignmentPropertiesPolicy"}, } def __init__( self, *, scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, **kwargs: Any ) -> None: """ :keyword scope: Details of the resource scope. :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope :keyword role_definition: Details of role definition. :paramtype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition :keyword policy: Details of the policy. :paramtype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ super().__init__(**kwargs) self.scope = scope self.role_definition = role_definition self.policy = policy class PolicyAssignmentPropertiesPolicy(_serialization.Model): """Details of the policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Id of the policy. :vartype id: str :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal :ivar last_modified_date_time: The last modified date time. :vartype last_modified_date_time: ~datetime.datetime """ _validation = { "last_modified_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "last_modified_by": {"key": "lastModifiedBy", "type": "Principal"}, "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin last_modified_date_time: Optional[datetime.datetime] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the policy. :paramtype id: str :keyword last_modified_date_time: The last modified date time. :paramtype last_modified_date_time: ~datetime.datetime """ super().__init__(**kwargs) self.id = id self.last_modified_by = None self.last_modified_date_time = last_modified_date_time class PolicyAssignmentPropertiesRoleDefinition(_serialization.Model): """Details of role definition. :ivar id: Id of the role definition. :vartype id: str :ivar display_name: Display name of the role definition. :vartype display_name: str :ivar type: Type of the role definition. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Id of the role definition. :paramtype id: str :keyword display_name: Display name of the role definition. :paramtype display_name: str :keyword type: Type of the role definition. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class PolicyAssignmentPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class PolicyProperties(_serialization.Model): """PolicyProperties. Variables are only populated by the server, and will be ignored when sending a request. :ivar scope: Details of the resource scope. :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyPropertiesScope """ _validation = { "scope": {"readonly": True}, } _attribute_map = { "scope": {"key": "scope", "type": "PolicyPropertiesScope"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.scope = None class PolicyPropertiesScope(_serialization.Model): """Details of the resource scope. :ivar id: Scope id of the resource. :vartype id: str :ivar display_name: Display name of the resource. :vartype display_name: str :ivar type: Type of the resource. :vartype type: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: Scope id of the resource. :paramtype id: str :keyword display_name: Display name of the resource. :paramtype display_name: str :keyword type: Type of the resource. :paramtype type: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment create parameters. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "scope": {"readonly": True}, "role_definition_id": {"required": True}, "principal_id": {"required": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentSchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignment schedule. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule Id. :vartype id: str :ivar name: The role assignment schedule name. :vartype name: str :ivar type: The role assignment schedule type. :vartype type: str :ivar scope: The role assignment schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule. :vartype role_assignment_schedule_request_id: str :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. :vartype linked_role_eligibility_schedule_id: str :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar status: The status of the role assignment schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: Start DateTime when role assignment schedule. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: End DateTime when role assignment schedule. :vartype end_date_time: ~datetime.datetime :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule was created. :vartype created_on: ~datetime.datetime :ivar updated_on: DateTime when role assignment schedule was modified. :vartype updated_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_assignment_schedule_request_id": {"key": "properties.roleAssignmentScheduleRequestId", "type": "str"}, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "assignment_type": {"key": "properties.assignmentType", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_assignment_schedule_request_id: Optional[str] = None, linked_role_eligibility_schedule_id: Optional[str] = None, assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule. :paramtype role_assignment_schedule_request_id: str :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. :paramtype linked_role_eligibility_schedule_id: str :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :keyword member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword status: The status of the role assignment schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: Start DateTime when role assignment schedule. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: End DateTime when role assignment schedule. :paramtype end_date_time: ~datetime.datetime :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role assignment schedule was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: DateTime when role assignment schedule was modified. :paramtype updated_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_assignment_schedule_request_id = role_assignment_schedule_request_id self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.assignment_type = assignment_type self.member_type = member_type self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.expanded_properties = expanded_properties class RoleAssignmentScheduleFilter(_serialization.Model): """Role assignment schedule filter. :ivar principal_id: Returns role assignment schedule of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment schedule of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role assignment schedule instances of the specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment schedule of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment schedule of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role assignment schedule instances of the specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status class RoleAssignmentScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Information about current or upcoming role assignment schedule instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule instance ID. :vartype id: str :ivar name: The role assignment schedule instance name. :vartype name: str :ivar type: The role assignment schedule instance type. :vartype type: str :ivar scope: The role assignment schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_assignment_schedule_id: Id of the master role assignment schedule. :vartype role_assignment_schedule_id: str :ivar origin_role_assignment_id: Role Assignment Id in external system. :vartype origin_role_assignment_id: str :ivar status: The status of the role assignment schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: The startDateTime of the role assignment schedule instance. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The endDateTime of the role assignment schedule instance. :vartype end_date_time: ~datetime.datetime :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. :vartype linked_role_eligibility_schedule_id: str :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to this roleAssignmentScheduleInstance. :vartype linked_role_eligibility_schedule_instance_id: str :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :ivar member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule was created. :vartype created_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_assignment_schedule_id": {"key": "properties.roleAssignmentScheduleId", "type": "str"}, "origin_role_assignment_id": {"key": "properties.originRoleAssignmentId", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "linked_role_eligibility_schedule_instance_id": { "key": "properties.linkedRoleEligibilityScheduleInstanceId", "type": "str", }, "assignment_type": {"key": "properties.assignmentType", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_assignment_schedule_id: Optional[str] = None, origin_role_assignment_id: Optional[str] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, linked_role_eligibility_schedule_id: Optional[str] = None, linked_role_eligibility_schedule_instance_id: Optional[str] = None, assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_assignment_schedule_id: Id of the master role assignment schedule. :paramtype role_assignment_schedule_id: str :keyword origin_role_assignment_id: Role Assignment Id in external system. :paramtype origin_role_assignment_id: str :keyword status: The status of the role assignment schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: The startDateTime of the role assignment schedule instance. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The endDateTime of the role assignment schedule instance. :paramtype end_date_time: ~datetime.datetime :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. :paramtype linked_role_eligibility_schedule_id: str :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to this roleAssignmentScheduleInstance. :paramtype linked_role_eligibility_schedule_instance_id: str :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: "Activated" and "Assigned". :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType :keyword member_type: Membership type of the role assignment schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role assignment schedule was created. :paramtype created_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_assignment_schedule_id = role_assignment_schedule_id self.origin_role_assignment_id = origin_role_assignment_id self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id self.assignment_type = assignment_type self.member_type = member_type self.condition = condition self.condition_version = condition_version self.created_on = created_on self.expanded_properties = expanded_properties class RoleAssignmentScheduleInstanceFilter(_serialization.Model): """Role assignment schedule instance filter. :ivar principal_id: Returns role assignment schedule instances of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment schedule instances of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role assignment schedule instances of the specific status. :vartype status: str :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a specific role assignment schedule. :vartype role_assignment_schedule_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, "role_assignment_schedule_id": {"key": "roleAssignmentScheduleId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, role_assignment_schedule_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment schedule instances of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment schedule instances of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role assignment schedule instances of the specific status. :paramtype status: str :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a specific role assignment schedule. :paramtype role_assignment_schedule_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status self.role_assignment_schedule_id = role_assignment_schedule_id class RoleAssignmentScheduleInstanceListResult(_serialization.Model): """Role assignment schedule instance list operation result. :ivar value: Role assignment schedule instance list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentScheduleInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule instance list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleListResult(_serialization.Model): """Role assignment schedule list operation result. :ivar value: Role assignment schedule list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentSchedule]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentSchedule"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignment schedule request. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment schedule request ID. :vartype id: str :ivar name: The role assignment schedule request name. :vartype name: str :ivar type: The role assignment schedule request type. :vartype type: str :ivar scope: The role assignment schedule request scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role assignment schedule request. :vartype approval_id: str :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role assignment schedule id being updated. :vartype target_role_assignment_schedule_id: str :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id being updated. :vartype target_role_assignment_schedule_instance_id: str :ivar schedule_info: Schedule info of the role assignment schedule. :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. :vartype linked_role_eligibility_schedule_id: str :ivar justification: Justification for the role assignment. :vartype justification: str :ivar ticket_info: Ticket Info of the role assignment. :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. :vartype requestor_id: str :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "principal_type": {"readonly": True}, "status": {"readonly": True}, "approval_id": {"readonly": True}, "created_on": {"readonly": True}, "requestor_id": {"readonly": True}, "expanded_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "request_type": {"key": "properties.requestType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "approval_id": {"key": "properties.approvalId", "type": "str"}, "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, "target_role_assignment_schedule_instance_id": { "key": "properties.targetRoleAssignmentScheduleInstanceId", "type": "str", }, "schedule_info": { "key": "properties.scheduleInfo", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", }, "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "requestor_id": {"key": "properties.requestorId", "type": "str"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, request_type: Optional[Union[str, "_models.RequestType"]] = None, target_role_assignment_schedule_id: Optional[str] = None, target_role_assignment_schedule_instance_id: Optional[str] = None, schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, linked_role_eligibility_schedule_id: Optional[str] = None, justification: Optional[str] = None, ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the role assignment schedule id being updated. :paramtype target_role_assignment_schedule_id: str :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id being updated. :paramtype target_role_assignment_schedule_instance_id: str :keyword schedule_info: Schedule info of the role assignment schedule. :paramtype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. :paramtype linked_role_eligibility_schedule_id: str :keyword justification: Justification for the role assignment. :paramtype justification: str :keyword ticket_info: Ticket Info of the role assignment. :paramtype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = None self.request_type = request_type self.status = None self.approval_id = None self.target_role_assignment_schedule_id = target_role_assignment_schedule_id self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id self.schedule_info = schedule_info self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id self.justification = justification self.ticket_info = ticket_info self.condition = condition self.condition_version = condition_version self.created_on = None self.requestor_id = None self.expanded_properties = None class RoleAssignmentScheduleRequestFilter(_serialization.Model): """Role assignment schedule request filter. :ivar principal_id: Returns role assignment requests of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role assignment requests of the specific role definition. :vartype role_definition_id: str :ivar requestor_id: Returns role assignment requests created by specific principal. :vartype requestor_id: str :ivar status: Returns role assignment requests of specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "requestor_id": {"key": "requestorId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, requestor_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment requests of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role assignment requests of the specific role definition. :paramtype role_definition_id: str :keyword requestor_id: Returns role assignment requests created by specific principal. :paramtype requestor_id: str :keyword status: Returns role assignment requests of specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.requestor_id = requestor_id self.status = status class RoleAssignmentScheduleRequestListResult(_serialization.Model): """Role assignment schedule request list operation result. :ivar value: Role assignment schedule request list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment schedule request list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): """Schedule info of the role assignment schedule. :ivar start_date_time: Start DateTime of the role assignment schedule. :vartype start_date_time: ~datetime.datetime :ivar expiration: Expiration of the role assignment schedule. :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration """ _attribute_map = { "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: Start DateTime of the role assignment schedule. :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role assignment schedule. :paramtype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): """Expiration of the role assignment schedule. :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :ivar end_date_time: End DateTime of the role assignment schedule. :vartype end_date_time: ~datetime.datetime :ivar duration: Duration of the role assignment schedule in TimeSpan. :vartype duration: str """ _attribute_map = { "type": {"key": "type", "type": "str"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "duration": {"key": "duration", "type": "str"}, } def __init__( self, *, type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :keyword end_date_time: End DateTime of the role assignment schedule. :paramtype end_date_time: ~datetime.datetime :keyword duration: Duration of the role assignment schedule in TimeSpan. :paramtype duration: str """ super().__init__(**kwargs) self.type = type self.end_date_time = end_date_time self.duration = duration class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): """Ticket Info of the role assignment. :ivar ticket_number: Ticket number for the role assignment. :vartype ticket_number: str :ivar ticket_system: Ticket system name for the role assignment. :vartype ticket_system: str """ _attribute_map = { "ticket_number": {"key": "ticketNumber", "type": "str"}, "ticket_system": {"key": "ticketSystem", "type": "str"}, } def __init__( self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword ticket_number: Ticket number for the role assignment. :paramtype ticket_number: str :keyword ticket_system: Ticket system name for the role assignment. :paramtype ticket_system: str """ super().__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system class RoleEligibilitySchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role eligibility schedule. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule Id. :vartype id: str :ivar name: The role eligibility schedule name. :vartype name: str :ivar type: The role eligibility schedule type. :vartype type: str :ivar scope: The role eligibility schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule. :vartype role_eligibility_schedule_request_id: str :ivar member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar status: The status of the role eligibility schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: Start DateTime when role eligibility schedule. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: End DateTime when role eligibility schedule. :vartype end_date_time: ~datetime.datetime :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule was created. :vartype created_on: ~datetime.datetime :ivar updated_on: DateTime when role eligibility schedule was modified. :vartype updated_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_eligibility_schedule_request_id": {"key": "properties.roleEligibilityScheduleRequestId", "type": "str"}, "member_type": {"key": "properties.memberType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_request_id: Optional[str] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role eligibility schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule. :paramtype role_eligibility_schedule_request_id: str :keyword member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword status: The status of the role eligibility schedule. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: Start DateTime when role eligibility schedule. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: End DateTime when role eligibility schedule. :paramtype end_date_time: ~datetime.datetime :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role eligibility schedule was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: DateTime when role eligibility schedule was modified. :paramtype updated_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id self.member_type = member_type self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.expanded_properties = expanded_properties class RoleEligibilityScheduleFilter(_serialization.Model): """Role eligibility schedule filter. :ivar principal_id: Returns role eligibility schedule of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role eligibility schedule of the specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility schedule of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role eligibility schedule of the specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status class RoleEligibilityScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Information about current or upcoming role eligibility schedule instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule instance ID. :vartype id: str :ivar name: The role eligibility schedule instance name. :vartype name: str :ivar type: The role eligibility schedule instance type. :vartype type: str :ivar scope: The role eligibility schedule scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. :vartype role_eligibility_schedule_id: str :ivar status: The status of the role eligibility schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar start_date_time: The startDateTime of the role eligibility schedule instance. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The endDateTime of the role eligibility schedule instance. :vartype end_date_time: ~datetime.datetime :ivar member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule was created. :vartype created_on: ~datetime.datetime :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "role_eligibility_schedule_id": {"key": "properties.roleEligibilityScheduleId", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "member_type": {"key": "properties.memberType", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, role_eligibility_schedule_id: Optional[str] = None, status: Optional[Union[str, "_models.Status"]] = None, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, member_type: Optional[Union[str, "_models.MemberType"]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, expanded_properties: Optional["_models.ExpandedProperties"] = None, **kwargs: Any ) -> None: """ :keyword scope: The role eligibility schedule scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. :paramtype role_eligibility_schedule_id: str :keyword status: The status of the role eligibility schedule instance. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :keyword start_date_time: The startDateTime of the role eligibility schedule instance. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The endDateTime of the role eligibility schedule instance. :paramtype end_date_time: ~datetime.datetime :keyword member_type: Membership type of the role eligibility schedule. Known values are: "Inherited", "Direct", and "Group". :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: DateTime when role eligibility schedule was created. :paramtype created_on: ~datetime.datetime :keyword expanded_properties: Additional properties of principal, scope and role definition. :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.role_eligibility_schedule_id = role_eligibility_schedule_id self.status = status self.start_date_time = start_date_time self.end_date_time = end_date_time self.member_type = member_type self.condition = condition self.condition_version = condition_version self.created_on = created_on self.expanded_properties = expanded_properties class RoleEligibilityScheduleInstanceFilter(_serialization.Model): """Role eligibility schedule instance filter. :ivar principal_id: Returns role eligibility schedule instances of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility schedule instances of the specific role definition. :vartype role_definition_id: str :ivar status: Returns role eligibility schedule instances of the specific status. :vartype status: str :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a specific role eligibility schedule. :vartype role_eligibility_schedule_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "status": {"key": "status", "type": "str"}, "role_eligibility_schedule_id": {"key": "roleEligibilityScheduleId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, status: Optional[str] = None, role_eligibility_schedule_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility schedule instances of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility schedule instances of the specific role definition. :paramtype role_definition_id: str :keyword status: Returns role eligibility schedule instances of the specific status. :paramtype status: str :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a specific role eligibility schedule. :paramtype role_eligibility_schedule_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.status = status self.role_eligibility_schedule_id = role_eligibility_schedule_id class RoleEligibilityScheduleInstanceListResult(_serialization.Model): """Role eligibility schedule instance list operation result. :ivar value: Role eligibility schedule instance list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilityScheduleInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role eligibility schedule instance list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleListResult(_serialization.Model): """role eligibility schedule list operation result. :ivar value: role eligibility schedule list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilitySchedule]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilitySchedule"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: role eligibility schedule list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Eligibility schedule request. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role eligibility schedule request ID. :vartype id: str :ivar name: The role eligibility schedule request name. :vartype name: str :ivar type: The role eligibility schedule request type. :vartype type: str :ivar scope: The role eligibility schedule request scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role eligibility schedule request. Known values are: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", and "PendingExternalProvisioning". :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role eligibility schedule request. :vartype approval_id: str :ivar schedule_info: Schedule info of the role eligibility schedule. :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. :vartype target_role_eligibility_schedule_id: str :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. :vartype target_role_eligibility_schedule_instance_id: str :ivar justification: Justification for the role eligibility. :vartype justification: str :ivar ticket_info: Ticket Info of the role eligibility. :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. :vartype requestor_id: str :ivar expanded_properties: Additional properties of principal, scope and role definition. :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "principal_type": {"readonly": True}, "status": {"readonly": True}, "approval_id": {"readonly": True}, "created_on": {"readonly": True}, "requestor_id": {"readonly": True}, "expanded_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "request_type": {"key": "properties.requestType", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "approval_id": {"key": "properties.approvalId", "type": "str"}, "schedule_info": { "key": "properties.scheduleInfo", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", }, "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, "target_role_eligibility_schedule_instance_id": { "key": "properties.targetRoleEligibilityScheduleInstanceId", "type": "str", }, "justification": {"key": "properties.justification", "type": "str"}, "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "requestor_id": {"key": "properties.requestorId", "type": "str"}, "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, request_type: Optional[Union[str, "_models.RequestType"]] = None, schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, target_role_eligibility_schedule_id: Optional[str] = None, target_role_eligibility_schedule_instance_id: Optional[str] = None, justification: Optional[str] = None, ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :keyword schedule_info: Schedule info of the role eligibility schedule. :paramtype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. :paramtype target_role_eligibility_schedule_id: str :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. :paramtype target_role_eligibility_schedule_instance_id: str :keyword justification: Justification for the role eligibility. :paramtype justification: str :keyword ticket_info: Ticket Info of the role eligibility. :paramtype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = None self.request_type = request_type self.status = None self.approval_id = None self.schedule_info = schedule_info self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id self.justification = justification self.ticket_info = ticket_info self.condition = condition self.condition_version = condition_version self.created_on = None self.requestor_id = None self.expanded_properties = None class RoleEligibilityScheduleRequestFilter(_serialization.Model): """Role eligibility schedule request filter. :ivar principal_id: Returns role eligibility requests of the specific principal. :vartype principal_id: str :ivar role_definition_id: Returns role eligibility requests of the specific role definition. :vartype role_definition_id: str :ivar requestor_id: Returns role eligibility requests created by specific principal. :vartype requestor_id: str :ivar status: Returns role eligibility requests of specific status. :vartype status: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "requestor_id": {"key": "requestorId", "type": "str"}, "status": {"key": "status", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, role_definition_id: Optional[str] = None, requestor_id: Optional[str] = None, status: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role eligibility requests of the specific principal. :paramtype principal_id: str :keyword role_definition_id: Returns role eligibility requests of the specific role definition. :paramtype role_definition_id: str :keyword requestor_id: Returns role eligibility requests created by specific principal. :paramtype requestor_id: str :keyword status: Returns role eligibility requests of specific status. :paramtype status: str """ super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id self.requestor_id = requestor_id self.status = status class RoleEligibilityScheduleRequestListResult(_serialization.Model): """Role eligibility schedule request list operation result. :ivar value: Role eligibility schedule request list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role eligibility schedule request list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): """Schedule info of the role eligibility schedule. :ivar start_date_time: Start DateTime of the role eligibility schedule. :vartype start_date_time: ~datetime.datetime :ivar expiration: Expiration of the role eligibility schedule. :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration """ _attribute_map = { "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: Start DateTime of the role eligibility schedule. :paramtype start_date_time: ~datetime.datetime :keyword expiration: Expiration of the role eligibility schedule. :paramtype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration """ super().__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): """Expiration of the role eligibility schedule. :ivar type: Type of the role eligibility schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :ivar end_date_time: End DateTime of the role eligibility schedule. :vartype end_date_time: ~datetime.datetime :ivar duration: Duration of the role eligibility schedule in TimeSpan. :vartype duration: str """ _attribute_map = { "type": {"key": "type", "type": "str"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "duration": {"key": "duration", "type": "str"}, } def __init__( self, *, type: Optional[Union[str, "_models.Type"]] = None, end_date_time: Optional[datetime.datetime] = None, duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword type: Type of the role eligibility schedule expiration. Known values are: "AfterDuration", "AfterDateTime", and "NoExpiration". :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type :keyword end_date_time: End DateTime of the role eligibility schedule. :paramtype end_date_time: ~datetime.datetime :keyword duration: Duration of the role eligibility schedule in TimeSpan. :paramtype duration: str """ super().__init__(**kwargs) self.type = type self.end_date_time = end_date_time self.duration = duration class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): """Ticket Info of the role eligibility. :ivar ticket_number: Ticket number for the role eligibility. :vartype ticket_number: str :ivar ticket_system: Ticket system name for the role eligibility. :vartype ticket_system: str """ _attribute_map = { "ticket_number": {"key": "ticketNumber", "type": "str"}, "ticket_system": {"key": "ticketSystem", "type": "str"}, } def __init__( self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword ticket_number: Ticket number for the role eligibility. :paramtype ticket_number: str :keyword ticket_system: Ticket system name for the role eligibility. :paramtype ticket_system: str """ super().__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system class RoleManagementPolicy(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role management policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role management policy Id. :vartype id: str :ivar name: The role management policy name. :vartype name: str :ivar type: The role management policy type. :vartype type: str :ivar scope: The role management policy scope. :vartype scope: str :ivar display_name: The role management policy display name. :vartype display_name: str :ivar description: The role management policy description. :vartype description: str :ivar is_organization_default: The role management policy is default policy. :vartype is_organization_default: bool :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal :ivar last_modified_date_time: The last modified date time. :vartype last_modified_date_time: ~datetime.datetime :ivar rules: The rule applied to the policy. :vartype rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] :ivar effective_rules: The readonly computed rule applied to the policy. :vartype effective_rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] :ivar policy_properties: Additional properties of scope. :vartype policy_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "last_modified_by": {"readonly": True}, "last_modified_date_time": {"readonly": True}, "effective_rules": {"readonly": True}, "policy_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "is_organization_default": {"key": "properties.isOrganizationDefault", "type": "bool"}, "last_modified_by": {"key": "properties.lastModifiedBy", "type": "Principal"}, "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, "rules": {"key": "properties.rules", "type": "[RoleManagementPolicyRule]"}, "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, "policy_properties": {"key": "properties.policyProperties", "type": "PolicyProperties"}, } def __init__( self, *, scope: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, is_organization_default: Optional[bool] = None, rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, **kwargs: Any ) -> None: """ :keyword scope: The role management policy scope. :paramtype scope: str :keyword display_name: The role management policy display name. :paramtype display_name: str :keyword description: The role management policy description. :paramtype description: str :keyword is_organization_default: The role management policy is default policy. :paramtype is_organization_default: bool :keyword rules: The rule applied to the policy. :paramtype rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.display_name = display_name self.description = description self.is_organization_default = is_organization_default self.last_modified_by = None self.last_modified_date_time = None self.rules = rules self.effective_rules = None self.policy_properties = None class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAssignment(_serialization.Model): """Role management policy. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role management policy Id. :vartype id: str :ivar name: The role management policy name. :vartype name: str :ivar type: The role management policy type. :vartype type: str :ivar scope: The role management policy scope. :vartype scope: str :ivar role_definition_id: The role definition of management policy assignment. :vartype role_definition_id: str :ivar policy_id: The policy id role management policy assignment. :vartype policy_id: str :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. :vartype policy_assignment_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "policy_assignment_properties": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "policy_id": {"key": "properties.policyId", "type": "str"}, "policy_assignment_properties": { "key": "properties.policyAssignmentProperties", "type": "PolicyAssignmentProperties", }, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, policy_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword scope: The role management policy scope. :paramtype scope: str :keyword role_definition_id: The role definition of management policy assignment. :paramtype role_definition_id: str :keyword policy_id: The policy id role management policy assignment. :paramtype policy_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.policy_id = policy_id self.policy_assignment_properties = None class RoleManagementPolicyAssignmentListResult(_serialization.Model): """Role management policy assignment list operation result. :ivar value: Role management policy assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleManagementPolicyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role management policy assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyListResult(_serialization.Model): """Role management policy list operation result. :ivar value: Role management policy list. :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleManagementPolicy]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleManagementPolicy"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role management policy list. :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description class ValidationResponse(_serialization.Model): """Validation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool :ivar error_info: Failed validation result details. :vartype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ _validation = { "is_valid": {"readonly": True}, } _attribute_map = { "is_valid": {"key": "isValid", "type": "bool"}, "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, } def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: """ :keyword error_info: Failed validation result details. :paramtype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ super().__init__(**kwargs) self.is_valid = None self.error_info = error_info class ValidationResponseErrorInfo(_serialization.Model): """Failed validation result details. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Error code indicating why validation failed. :vartype code: str :ivar message: Message indicating why validation failed. :vartype message: str """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None
0.855142
0.272487
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import CloudErrorBody from ._models_py3 import EligibleChildResource from ._models_py3 import EligibleChildResourcesListResult from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import ExpandedProperties from ._models_py3 import ExpandedPropertiesPrincipal from ._models_py3 import ExpandedPropertiesRoleDefinition from ._models_py3 import ExpandedPropertiesScope from ._models_py3 import Permission from ._models_py3 import PolicyAssignmentProperties from ._models_py3 import PolicyAssignmentPropertiesPolicy from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition from ._models_py3 import PolicyAssignmentPropertiesScope from ._models_py3 import PolicyProperties from ._models_py3 import PolicyPropertiesScope from ._models_py3 import Principal from ._models_py3 import RoleAssignment from ._models_py3 import RoleAssignmentCreateParameters from ._models_py3 import RoleAssignmentFilter from ._models_py3 import RoleAssignmentListResult from ._models_py3 import RoleAssignmentSchedule from ._models_py3 import RoleAssignmentScheduleFilter from ._models_py3 import RoleAssignmentScheduleInstance from ._models_py3 import RoleAssignmentScheduleInstanceFilter from ._models_py3 import RoleAssignmentScheduleInstanceListResult from ._models_py3 import RoleAssignmentScheduleListResult from ._models_py3 import RoleAssignmentScheduleRequest from ._models_py3 import RoleAssignmentScheduleRequestFilter from ._models_py3 import RoleAssignmentScheduleRequestListResult from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo from ._models_py3 import RoleEligibilitySchedule from ._models_py3 import RoleEligibilityScheduleFilter from ._models_py3 import RoleEligibilityScheduleInstance from ._models_py3 import RoleEligibilityScheduleInstanceFilter from ._models_py3 import RoleEligibilityScheduleInstanceListResult from ._models_py3 import RoleEligibilityScheduleListResult from ._models_py3 import RoleEligibilityScheduleRequest from ._models_py3 import RoleEligibilityScheduleRequestFilter from ._models_py3 import RoleEligibilityScheduleRequestListResult from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo from ._models_py3 import RoleManagementPolicy from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAssignment from ._models_py3 import RoleManagementPolicyAssignmentListResult from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyListResult from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._models_py3 import ValidationResponse from ._models_py3 import ValidationResponseErrorInfo from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import AssignmentType from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import MemberType from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import PrincipalType from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RequestType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import Status from ._authorization_management_client_enums import Type from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "CloudErrorBody", "EligibleChildResource", "EligibleChildResourcesListResult", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "ExpandedProperties", "ExpandedPropertiesPrincipal", "ExpandedPropertiesRoleDefinition", "ExpandedPropertiesScope", "Permission", "PolicyAssignmentProperties", "PolicyAssignmentPropertiesPolicy", "PolicyAssignmentPropertiesRoleDefinition", "PolicyAssignmentPropertiesScope", "PolicyProperties", "PolicyPropertiesScope", "Principal", "RoleAssignment", "RoleAssignmentCreateParameters", "RoleAssignmentFilter", "RoleAssignmentListResult", "RoleAssignmentSchedule", "RoleAssignmentScheduleFilter", "RoleAssignmentScheduleInstance", "RoleAssignmentScheduleInstanceFilter", "RoleAssignmentScheduleInstanceListResult", "RoleAssignmentScheduleListResult", "RoleAssignmentScheduleRequest", "RoleAssignmentScheduleRequestFilter", "RoleAssignmentScheduleRequestListResult", "RoleAssignmentScheduleRequestPropertiesScheduleInfo", "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", "RoleAssignmentScheduleRequestPropertiesTicketInfo", "RoleEligibilitySchedule", "RoleEligibilityScheduleFilter", "RoleEligibilityScheduleInstance", "RoleEligibilityScheduleInstanceFilter", "RoleEligibilityScheduleInstanceListResult", "RoleEligibilityScheduleListResult", "RoleEligibilityScheduleRequest", "RoleEligibilityScheduleRequestFilter", "RoleEligibilityScheduleRequestListResult", "RoleEligibilityScheduleRequestPropertiesScheduleInfo", "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", "RoleEligibilityScheduleRequestPropertiesTicketInfo", "RoleManagementPolicy", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAssignment", "RoleManagementPolicyAssignmentListResult", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyListResult", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ValidationResponse", "ValidationResponseErrorInfo", "ApprovalMode", "AssignmentType", "EnablementRules", "MemberType", "NotificationDeliveryMechanism", "NotificationLevel", "PrincipalType", "RecipientType", "RequestType", "RoleManagementPolicyRuleType", "Status", "Type", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py
__init__.py
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import CloudErrorBody from ._models_py3 import EligibleChildResource from ._models_py3 import EligibleChildResourcesListResult from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import ExpandedProperties from ._models_py3 import ExpandedPropertiesPrincipal from ._models_py3 import ExpandedPropertiesRoleDefinition from ._models_py3 import ExpandedPropertiesScope from ._models_py3 import Permission from ._models_py3 import PolicyAssignmentProperties from ._models_py3 import PolicyAssignmentPropertiesPolicy from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition from ._models_py3 import PolicyAssignmentPropertiesScope from ._models_py3 import PolicyProperties from ._models_py3 import PolicyPropertiesScope from ._models_py3 import Principal from ._models_py3 import RoleAssignment from ._models_py3 import RoleAssignmentCreateParameters from ._models_py3 import RoleAssignmentFilter from ._models_py3 import RoleAssignmentListResult from ._models_py3 import RoleAssignmentSchedule from ._models_py3 import RoleAssignmentScheduleFilter from ._models_py3 import RoleAssignmentScheduleInstance from ._models_py3 import RoleAssignmentScheduleInstanceFilter from ._models_py3 import RoleAssignmentScheduleInstanceListResult from ._models_py3 import RoleAssignmentScheduleListResult from ._models_py3 import RoleAssignmentScheduleRequest from ._models_py3 import RoleAssignmentScheduleRequestFilter from ._models_py3 import RoleAssignmentScheduleRequestListResult from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo from ._models_py3 import RoleEligibilitySchedule from ._models_py3 import RoleEligibilityScheduleFilter from ._models_py3 import RoleEligibilityScheduleInstance from ._models_py3 import RoleEligibilityScheduleInstanceFilter from ._models_py3 import RoleEligibilityScheduleInstanceListResult from ._models_py3 import RoleEligibilityScheduleListResult from ._models_py3 import RoleEligibilityScheduleRequest from ._models_py3 import RoleEligibilityScheduleRequestFilter from ._models_py3 import RoleEligibilityScheduleRequestListResult from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo from ._models_py3 import RoleManagementPolicy from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAssignment from ._models_py3 import RoleManagementPolicyAssignmentListResult from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyListResult from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._models_py3 import ValidationResponse from ._models_py3 import ValidationResponseErrorInfo from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import AssignmentType from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import MemberType from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import PrincipalType from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RequestType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import Status from ._authorization_management_client_enums import Type from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "CloudErrorBody", "EligibleChildResource", "EligibleChildResourcesListResult", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "ExpandedProperties", "ExpandedPropertiesPrincipal", "ExpandedPropertiesRoleDefinition", "ExpandedPropertiesScope", "Permission", "PolicyAssignmentProperties", "PolicyAssignmentPropertiesPolicy", "PolicyAssignmentPropertiesRoleDefinition", "PolicyAssignmentPropertiesScope", "PolicyProperties", "PolicyPropertiesScope", "Principal", "RoleAssignment", "RoleAssignmentCreateParameters", "RoleAssignmentFilter", "RoleAssignmentListResult", "RoleAssignmentSchedule", "RoleAssignmentScheduleFilter", "RoleAssignmentScheduleInstance", "RoleAssignmentScheduleInstanceFilter", "RoleAssignmentScheduleInstanceListResult", "RoleAssignmentScheduleListResult", "RoleAssignmentScheduleRequest", "RoleAssignmentScheduleRequestFilter", "RoleAssignmentScheduleRequestListResult", "RoleAssignmentScheduleRequestPropertiesScheduleInfo", "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", "RoleAssignmentScheduleRequestPropertiesTicketInfo", "RoleEligibilitySchedule", "RoleEligibilityScheduleFilter", "RoleEligibilityScheduleInstance", "RoleEligibilityScheduleInstanceFilter", "RoleEligibilityScheduleInstanceListResult", "RoleEligibilityScheduleListResult", "RoleEligibilityScheduleRequest", "RoleEligibilityScheduleRequestFilter", "RoleEligibilityScheduleRequestListResult", "RoleEligibilityScheduleRequestPropertiesScheduleInfo", "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", "RoleEligibilityScheduleRequestPropertiesTicketInfo", "RoleManagementPolicy", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAssignment", "RoleManagementPolicyAssignmentListResult", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyListResult", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ValidationResponse", "ValidationResponseErrorInfo", "ApprovalMode", "AssignmentType", "EnablementRules", "MemberType", "NotificationDeliveryMechanism", "NotificationLevel", "PrincipalType", "RecipientType", "RequestType", "RoleManagementPolicyRuleType", "Status", "Type", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.476823
0.075244
from enum import Enum from azure.core import CaseInsensitiveEnumMeta class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule.""" SINGLE_STAGE = "SingleStage" SERIAL = "Serial" PARALLEL = "Parallel" NO_APPROVAL = "NoApproval" class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Assignment type of the role assignment schedule.""" ACTIVATED = "Activated" ASSIGNED = "Assigned" class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of enablement rule.""" MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" JUSTIFICATION = "Justification" TICKETING = "Ticketing" class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Membership type of the role assignment schedule.""" INHERITED = "Inherited" DIRECT = "Direct" GROUP = "Group" class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of notification.""" EMAIL = "Email" class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The notification level.""" NONE = "None" CRITICAL = "Critical" ALL = "All" class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principal type of the assigned principal ID.""" USER = "User" GROUP = "Group" SERVICE_PRINCIPAL = "ServicePrincipal" FOREIGN_GROUP = "ForeignGroup" DEVICE = "Device" class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recipient type.""" REQUESTOR = "Requestor" APPROVER = "Approver" ADMIN = "Admin" class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" ADMIN_ASSIGN = "AdminAssign" ADMIN_REMOVE = "AdminRemove" ADMIN_UPDATE = "AdminUpdate" ADMIN_EXTEND = "AdminExtend" ADMIN_RENEW = "AdminRenew" SELF_ACTIVATE = "SelfActivate" SELF_DEACTIVATE = "SelfDeactivate" SELF_EXTEND = "SelfExtend" SELF_RENEW = "SelfRenew" class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule.""" ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the role assignment schedule.""" ACCEPTED = "Accepted" PENDING_EVALUATION = "PendingEvaluation" GRANTED = "Granted" DENIED = "Denied" PENDING_PROVISIONING = "PendingProvisioning" PROVISIONED = "Provisioned" PENDING_REVOCATION = "PendingRevocation" REVOKED = "Revoked" CANCELED = "Canceled" FAILED = "Failed" PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" PENDING_APPROVAL = "PendingApproval" FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" PENDING_ADMIN_DECISION = "PendingAdminDecision" ADMIN_APPROVED = "AdminApproved" ADMIN_DENIED = "AdminDenied" TIMED_OUT = "TimedOut" PROVISIONING_STARTED = "ProvisioningStarted" INVALID = "Invalid" PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" SCHEDULE_CREATED = "ScheduleCreated" PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the role assignment schedule expiration.""" AFTER_DURATION = "AfterDuration" AFTER_DATE_TIME = "AfterDateTime" NO_EXPIRATION = "NoExpiration" class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of user.""" USER = "User" GROUP = "Group"
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py
_authorization_management_client_enums.py
from enum import Enum from azure.core import CaseInsensitiveEnumMeta class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule.""" SINGLE_STAGE = "SingleStage" SERIAL = "Serial" PARALLEL = "Parallel" NO_APPROVAL = "NoApproval" class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Assignment type of the role assignment schedule.""" ACTIVATED = "Activated" ASSIGNED = "Assigned" class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of enablement rule.""" MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" JUSTIFICATION = "Justification" TICKETING = "Ticketing" class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Membership type of the role assignment schedule.""" INHERITED = "Inherited" DIRECT = "Direct" GROUP = "Group" class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of notification.""" EMAIL = "Email" class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The notification level.""" NONE = "None" CRITICAL = "Critical" ALL = "All" class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principal type of the assigned principal ID.""" USER = "User" GROUP = "Group" SERVICE_PRINCIPAL = "ServicePrincipal" FOREIGN_GROUP = "ForeignGroup" DEVICE = "Device" class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The recipient type.""" REQUESTOR = "Requestor" APPROVER = "Approver" ADMIN = "Admin" class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" ADMIN_ASSIGN = "AdminAssign" ADMIN_REMOVE = "AdminRemove" ADMIN_UPDATE = "AdminUpdate" ADMIN_EXTEND = "AdminExtend" ADMIN_RENEW = "AdminRenew" SELF_ACTIVATE = "SelfActivate" SELF_DEACTIVATE = "SelfDeactivate" SELF_EXTEND = "SelfExtend" SELF_RENEW = "SelfRenew" class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of rule.""" ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the role assignment schedule.""" ACCEPTED = "Accepted" PENDING_EVALUATION = "PendingEvaluation" GRANTED = "Granted" DENIED = "Denied" PENDING_PROVISIONING = "PendingProvisioning" PROVISIONED = "Provisioned" PENDING_REVOCATION = "PendingRevocation" REVOKED = "Revoked" CANCELED = "Canceled" FAILED = "Failed" PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" PENDING_APPROVAL = "PendingApproval" FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" PENDING_ADMIN_DECISION = "PendingAdminDecision" ADMIN_APPROVED = "AdminApproved" ADMIN_DENIED = "AdminDenied" TIMED_OUT = "TimedOut" PROVISIONING_STARTED = "ProvisioningStarted" INVALID = "Invalid" PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" SCHEDULE_CREATED = "ScheduleCreated" PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the role assignment schedule expiration.""" AFTER_DURATION = "AfterDuration" AFTER_DATE_TIME = "AfterDateTime" NO_EXPIRATION = "NoExpiration" class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of user.""" USER = "User" GROUP = "Group"
0.8067
0.090494
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.845847
0.107907
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.833189
0.085213
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_metrics_for_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentMetricsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2019_08_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_metrics` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_metrics_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_metrics_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py
_role_assignment_metrics_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_metrics_for_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentMetricsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2019_08_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_metrics` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_metrics_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_metrics_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" }
0.843638
0.075551
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignment_metrics = RoleAssignmentMetricsOperations( self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.831451
0.115038
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.835551
0.087136
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_metrics_operations import build_get_metrics_for_subscription_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentMetricsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2019_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_metrics` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_metrics_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_metrics_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py
_role_assignment_metrics_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_metrics_operations import build_get_metrics_for_subscription_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentMetricsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2019_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_metrics` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: """Get role assignment usage metrics for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentMetricsResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") ) cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) request = build_get_metrics_for_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_metrics_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_metrics_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" }
0.871393
0.085099
from typing import Any, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignmentMetricsResult(_serialization.Model): """Role Assignment Metrics. Variables are only populated by the server, and will be ignored when sending a request. :ivar subscription_id: The subscription ID. :vartype subscription_id: str :ivar role_assignments_limit: The role assignment limit. :vartype role_assignments_limit: int :ivar role_assignments_current_count: The number of current role assignments. :vartype role_assignments_current_count: int :ivar role_assignments_remaining_count: The number of remaining role assignments available. :vartype role_assignments_remaining_count: int """ _validation = { "subscription_id": {"readonly": True}, "role_assignments_limit": {"readonly": True}, "role_assignments_current_count": {"readonly": True}, "role_assignments_remaining_count": {"readonly": True}, } _attribute_map = { "subscription_id": {"key": "subscriptionId", "type": "str"}, "role_assignments_limit": {"key": "roleAssignmentsLimit", "type": "int"}, "role_assignments_current_count": {"key": "roleAssignmentsCurrentCount", "type": "int"}, "role_assignments_remaining_count": {"key": "roleAssignmentsRemainingCount", "type": "int"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.subscription_id = None self.role_assignments_limit = None self.role_assignments_current_count = None self.role_assignments_remaining_count = None
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py
_models_py3.py
from typing import Any, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignmentMetricsResult(_serialization.Model): """Role Assignment Metrics. Variables are only populated by the server, and will be ignored when sending a request. :ivar subscription_id: The subscription ID. :vartype subscription_id: str :ivar role_assignments_limit: The role assignment limit. :vartype role_assignments_limit: int :ivar role_assignments_current_count: The number of current role assignments. :vartype role_assignments_current_count: int :ivar role_assignments_remaining_count: The number of remaining role assignments available. :vartype role_assignments_remaining_count: int """ _validation = { "subscription_id": {"readonly": True}, "role_assignments_limit": {"readonly": True}, "role_assignments_current_count": {"readonly": True}, "role_assignments_remaining_count": {"readonly": True}, } _attribute_map = { "subscription_id": {"key": "subscriptionId", "type": "str"}, "role_assignments_limit": {"key": "roleAssignmentsLimit", "type": "int"}, "role_assignments_current_count": {"key": "roleAssignmentsCurrentCount", "type": "int"}, "role_assignments_remaining_count": {"key": "roleAssignmentsRemainingCount", "type": "int"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.subscription_id = None self.role_assignments_limit = None self.role_assignments_current_count = None self.role_assignments_remaining_count = None
0.894141
0.269243
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.787564
0.080792
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.832237
0.091018
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_by_id_request( schedule_definition_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py
_access_review_schedule_definitions_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_by_id_request( schedule_definition_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.784154
0.090454
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py
_access_review_instance_contacted_reviewers_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.843799
0.087564
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload def create( self, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py
_access_review_instances_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload def create( self, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.839668
0.095139
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceMyDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py
_access_review_instance_my_decisions_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceMyDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
0.825132
0.085633
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py
_access_review_schedule_definitions_assigned_for_my_approval_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
0.846181
0.087097
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py
_access_review_instance_decisions_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request( schedule_definition_id: str, id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
0.861582
0.086054
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class TenantLevelAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py
_tenant_level_access_review_instance_contacted_reviewers_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class TenantLevelAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.812496
0.084909
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstancesAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py
_access_review_instances_assigned_for_my_approval_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstancesAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.832203
0.087759
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_stop_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_reset_decisions_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_apply_decisions_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_send_reminders_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_accept_recommendations_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py
_access_review_instance_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_stop_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_reset_decisions_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_apply_decisions_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_send_reminders_request( schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_accept_recommendations_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
0.783658
0.086555
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py
_access_review_default_settings_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
0.867359
0.073397
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py
_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
0.841858
0.079032
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.785473
0.085862
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.836855
0.093347
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py
_access_review_schedule_definitions_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.879121
0.084682
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py
_access_review_instance_contacted_reviewers_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.857112
0.099164
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload async def create( self, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py
_access_review_instances_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload async def create( self, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.89138
0.098729
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceMyDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py
_access_review_instance_my_decisions_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceMyDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
0.892261
0.087798
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py
_access_review_schedule_definitions_assigned_for_my_approval_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
0.881736
0.103612
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py
_access_review_instance_decisions_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_decisions_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
0.883431
0.105303
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantLevelAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py
_tenant_level_access_review_instance_contacted_reviewers_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantLevelAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.863823
0.096706
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstancesAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py
_access_review_instances_assigned_for_my_approval_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstancesAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.890853
0.09314
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py
_access_review_instance_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
0.903072
0.09886
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload async def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py
_access_review_default_settings_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload async def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
0.90424
0.07333
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py
_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
0.870831
0.092524
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class AccessReviewContactedReviewer(_serialization.Model): """Access Review Contacted Reviewer. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review reviewer id. :vartype id: str :ivar name: The access review reviewer id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar user_display_name: The display name of the reviewer. :vartype user_display_name: str :ivar user_principal_name: The user principal name of the reviewer. :vartype user_principal_name: str :ivar created_date_time: Date Time when the reviewer was contacted. :vartype created_date_time: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "user_display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, "created_date_time": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.user_display_name = None self.user_principal_name = None self.created_date_time = None class AccessReviewContactedReviewerListResult(_serialization.Model): """List of access review contacted reviewers. :ivar value: Access Review Contacted Reviewer. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Contacted Reviewer. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review decision id. :vartype id: str :ivar name: The access review decision name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar principal_id_properties_applied_by_principal_id: The identity id. :vartype principal_id_properties_applied_by_principal_id: str :ivar principal_type_properties_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_applied_by_principal_name: The identity display name. :vartype principal_name_properties_applied_by_principal_name: str :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_applied_by_user_principal_name: str :ivar principal_id_properties_reviewed_by_principal_id: The identity id. :vartype principal_id_properties_reviewed_by_principal_id: str :ivar principal_type_properties_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. :vartype principal_name_properties_reviewed_by_principal_name: str :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str :ivar type_properties_resource_type: The type of resource. "azureRole" :vartype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id_properties_resource_id: The id of resource associated with a decision record. :vartype id_properties_resource_id: str :ivar display_name_properties_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_properties_resource_display_name: str :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_properties_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id_properties_principal_id: The id of principal whose access was reviewed. :vartype id_properties_principal_id: str :ivar display_name_properties_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_properties_principal_display_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_properties_applied_by_principal_id": {"readonly": True}, "principal_type_properties_applied_by_principal_type": {"readonly": True}, "principal_name_properties_applied_by_principal_name": {"readonly": True}, "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, "id_properties_resource_id": {"readonly": True}, "display_name_properties_resource_display_name": {"readonly": True}, "id_properties_principal_id": {"readonly": True}, "display_name_properties_principal_display_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "recommendation": {"key": "properties.recommendation", "type": "str"}, "decision": {"key": "properties.decision", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "properties.applyResult", "type": "str"}, "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, "principal_type_properties_applied_by_principal_type": { "key": "properties.appliedBy.principalType", "type": "str", }, "principal_name_properties_applied_by_principal_name": { "key": "properties.appliedBy.principalName", "type": "str", }, "user_principal_name_properties_applied_by_user_principal_name": { "key": "properties.appliedBy.userPrincipalName", "type": "str", }, "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type_properties_reviewed_by_principal_type": { "key": "properties.reviewedBy.principalType", "type": "str", }, "principal_name_properties_reviewed_by_principal_name": { "key": "properties.reviewedBy.principalName", "type": "str", }, "user_principal_name_properties_reviewed_by_user_principal_name": { "key": "properties.reviewedBy.userPrincipalName", "type": "str", }, "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.principal_id_properties_applied_by_principal_id = None self.principal_type_properties_applied_by_principal_type = None self.principal_name_properties_applied_by_principal_name = None self.user_principal_name_properties_applied_by_user_principal_name = None self.principal_id_properties_reviewed_by_principal_id = None self.principal_type_properties_reviewed_by_principal_type = None self.principal_name_properties_reviewed_by_principal_name = None self.user_principal_name_properties_reviewed_by_user_principal_name = None self.type_properties_resource_type: Optional[str] = None self.id_properties_resource_id = None self.display_name_properties_resource_display_name = None self.type_properties_principal_type: Optional[str] = None self.id_properties_principal_id = None self.display_name_properties_principal_display_name = None class AccessReviewDecisionIdentity(_serialization.Model): """Target of the decision. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } _subtype_map = { "type": { "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", "user": "AccessReviewDecisionUserIdentity", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionListResult(_serialization.Model): """List of access review decisions. :ivar value: Access Review Decision list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewDecision]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Decision list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar principal_id_applied_by_principal_id: The identity id. :vartype principal_id_applied_by_principal_id: str :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_applied_by_principal_name: The identity display name. :vartype principal_name_applied_by_principal_name: str :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_applied_by_user_principal_name: str :ivar principal_id_reviewed_by_principal_id: The identity id. :vartype principal_id_reviewed_by_principal_id: str :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_reviewed_by_principal_name: The identity display name. :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str :ivar type_resource_type: The type of resource. "azureRole" :vartype type_resource_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id_resource_id: The id of resource associated with a decision record. :vartype id_resource_id: str :ivar display_name_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_resource_display_name: str :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id_principal_id: The id of principal whose access was reviewed. :vartype id_principal_id: str :ivar display_name_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_principal_display_name: str """ _validation = { "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_applied_by_principal_id": {"readonly": True}, "principal_type_applied_by_principal_type": {"readonly": True}, "principal_name_applied_by_principal_name": {"readonly": True}, "user_principal_name_applied_by_user_principal_name": {"readonly": True}, "principal_id_reviewed_by_principal_id": {"readonly": True}, "principal_type_reviewed_by_principal_type": {"readonly": True}, "principal_name_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, "id_resource_id": {"readonly": True}, "display_name_resource_display_name": {"readonly": True}, "id_principal_id": {"readonly": True}, "display_name_principal_display_name": {"readonly": True}, } _attribute_map = { "recommendation": {"key": "recommendation", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "applyResult", "type": "str"}, "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, "type_resource_type": {"key": "resource.type", "type": "str"}, "id_resource_id": {"key": "resource.id", "type": "str"}, "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, "type_principal_type": {"key": "principal.type", "type": "str"}, "id_principal_id": {"key": "principal.id", "type": "str"}, "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.principal_id_applied_by_principal_id = None self.principal_type_applied_by_principal_type = None self.principal_name_applied_by_principal_name = None self.user_principal_name_applied_by_user_principal_name = None self.principal_id_reviewed_by_principal_id = None self.principal_type_reviewed_by_principal_type = None self.principal_name_reviewed_by_principal_name = None self.user_principal_name_reviewed_by_user_principal_name = None self.type_resource_type: Optional[str] = None self.id_resource_id = None self.display_name_resource_display_name = None self.type_principal_type: Optional[str] = None self.id_principal_id = None self.display_name_principal_display_name = None class AccessReviewDecisionResource(_serialization.Model): """Target of the decision. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of resource. Required. "azureRole" :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id: The id of resource associated with a decision record. :vartype id: str :ivar display_name: The display name of resource associated with a decision record. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): """Service Principal Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar app_id: The appId for the service principal entity being reviewed. :vartype app_id: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "app_id": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "app_id": {"key": "appId", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "servicePrincipal" self.app_id = None class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar user_principal_name: The user principal name of the user whose access was reviewed. :vartype user_principal_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "user_principal_name": {"key": "userPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "user" self.user_principal_name = None class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Default Settings. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review default settings id. This is only going to be default. :vartype id: str :ivar name: The access review default settings name. This is always going to be Access Review Default Settings. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "properties.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_recurrence_range_type = type_properties_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type self.interval = interval class AccessReviewInstance(_serialization.Model): """Access Review Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review instance id. :vartype id: str :ivar name: The access review instance name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewInstanceListResult(_serialization.Model): """List of Access Review Instances. :ivar value: Access Review Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewInstanceProperties(_serialization.Model): """Access Review Instance properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "status": {"key": "status", "type": "str"}, "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewReviewer(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of the reviewer(user/servicePrincipal). :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewerType """ _validation = { "principal_type": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: The id of the reviewer(user/servicePrincipal). :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.principal_type = None class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Schedule Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review schedule definition id. :vartype id: str :ivar name: The access review schedule definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_properties_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_properties_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": { "key": "properties.settings.justificationRequiredOnApproval", "type": "bool", }, "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": { "key": "properties.settings.recommendationLookBackDuration", "type": "duration", }, "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, "type_properties_settings_recurrence_range_type": { "key": "properties.settings.recurrence.range.type", "type": "str", }, "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_settings_recurrence_pattern_type": { "key": "properties.settings.recurrence.pattern.type", "type": "str", }, "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type_properties_created_by_principal_type": { "key": "properties.createdBy.principalType", "type": "str", }, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_settings_recurrence_range_type: Optional[ Union[str, "_models.AccessReviewRecurrenceRangeType"] ] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_properties_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_properties_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleDefinitionListResult(_serialization.Model): """List of Access Review Schedule Definitions. :ivar value: Access Review Schedule Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Schedule Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "scope.resourceId", "type": "str"}, "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, "assignment_state": {"key": "scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_settings_recurrence_range_type = type_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Settings of an Access Review. :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _attribute_map = { "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, "interval": {"key": "recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_recurrence_range_type = type_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_recurrence_pattern_type = type_recurrence_pattern_type self.interval = interval class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py
_models_py3.py
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class AccessReviewContactedReviewer(_serialization.Model): """Access Review Contacted Reviewer. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review reviewer id. :vartype id: str :ivar name: The access review reviewer id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar user_display_name: The display name of the reviewer. :vartype user_display_name: str :ivar user_principal_name: The user principal name of the reviewer. :vartype user_principal_name: str :ivar created_date_time: Date Time when the reviewer was contacted. :vartype created_date_time: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "user_display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, "created_date_time": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.user_display_name = None self.user_principal_name = None self.created_date_time = None class AccessReviewContactedReviewerListResult(_serialization.Model): """List of access review contacted reviewers. :ivar value: Access Review Contacted Reviewer. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Contacted Reviewer. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review decision id. :vartype id: str :ivar name: The access review decision name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar principal_id_properties_applied_by_principal_id: The identity id. :vartype principal_id_properties_applied_by_principal_id: str :ivar principal_type_properties_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_applied_by_principal_name: The identity display name. :vartype principal_name_properties_applied_by_principal_name: str :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_applied_by_user_principal_name: str :ivar principal_id_properties_reviewed_by_principal_id: The identity id. :vartype principal_id_properties_reviewed_by_principal_id: str :ivar principal_type_properties_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. :vartype principal_name_properties_reviewed_by_principal_name: str :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str :ivar type_properties_resource_type: The type of resource. "azureRole" :vartype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id_properties_resource_id: The id of resource associated with a decision record. :vartype id_properties_resource_id: str :ivar display_name_properties_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_properties_resource_display_name: str :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_properties_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id_properties_principal_id: The id of principal whose access was reviewed. :vartype id_properties_principal_id: str :ivar display_name_properties_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_properties_principal_display_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_properties_applied_by_principal_id": {"readonly": True}, "principal_type_properties_applied_by_principal_type": {"readonly": True}, "principal_name_properties_applied_by_principal_name": {"readonly": True}, "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, "id_properties_resource_id": {"readonly": True}, "display_name_properties_resource_display_name": {"readonly": True}, "id_properties_principal_id": {"readonly": True}, "display_name_properties_principal_display_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "recommendation": {"key": "properties.recommendation", "type": "str"}, "decision": {"key": "properties.decision", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "properties.applyResult", "type": "str"}, "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, "principal_type_properties_applied_by_principal_type": { "key": "properties.appliedBy.principalType", "type": "str", }, "principal_name_properties_applied_by_principal_name": { "key": "properties.appliedBy.principalName", "type": "str", }, "user_principal_name_properties_applied_by_user_principal_name": { "key": "properties.appliedBy.userPrincipalName", "type": "str", }, "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type_properties_reviewed_by_principal_type": { "key": "properties.reviewedBy.principalType", "type": "str", }, "principal_name_properties_reviewed_by_principal_name": { "key": "properties.reviewedBy.principalName", "type": "str", }, "user_principal_name_properties_reviewed_by_user_principal_name": { "key": "properties.reviewedBy.userPrincipalName", "type": "str", }, "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.principal_id_properties_applied_by_principal_id = None self.principal_type_properties_applied_by_principal_type = None self.principal_name_properties_applied_by_principal_name = None self.user_principal_name_properties_applied_by_user_principal_name = None self.principal_id_properties_reviewed_by_principal_id = None self.principal_type_properties_reviewed_by_principal_type = None self.principal_name_properties_reviewed_by_principal_name = None self.user_principal_name_properties_reviewed_by_user_principal_name = None self.type_properties_resource_type: Optional[str] = None self.id_properties_resource_id = None self.display_name_properties_resource_display_name = None self.type_properties_principal_type: Optional[str] = None self.id_properties_principal_id = None self.display_name_properties_principal_display_name = None class AccessReviewDecisionIdentity(_serialization.Model): """Target of the decision. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } _subtype_map = { "type": { "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", "user": "AccessReviewDecisionUserIdentity", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionListResult(_serialization.Model): """List of access review decisions. :ivar value: Access Review Decision list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewDecision]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Decision list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar principal_id_applied_by_principal_id: The identity id. :vartype principal_id_applied_by_principal_id: str :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_applied_by_principal_name: The identity display name. :vartype principal_name_applied_by_principal_name: str :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_applied_by_user_principal_name: str :ivar principal_id_reviewed_by_principal_id: The identity id. :vartype principal_id_reviewed_by_principal_id: str :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_reviewed_by_principal_name: The identity display name. :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str :ivar type_resource_type: The type of resource. "azureRole" :vartype type_resource_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id_resource_id: The id of resource associated with a decision record. :vartype id_resource_id: str :ivar display_name_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_resource_display_name: str :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id_principal_id: The id of principal whose access was reviewed. :vartype id_principal_id: str :ivar display_name_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_principal_display_name: str """ _validation = { "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_applied_by_principal_id": {"readonly": True}, "principal_type_applied_by_principal_type": {"readonly": True}, "principal_name_applied_by_principal_name": {"readonly": True}, "user_principal_name_applied_by_user_principal_name": {"readonly": True}, "principal_id_reviewed_by_principal_id": {"readonly": True}, "principal_type_reviewed_by_principal_type": {"readonly": True}, "principal_name_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, "id_resource_id": {"readonly": True}, "display_name_resource_display_name": {"readonly": True}, "id_principal_id": {"readonly": True}, "display_name_principal_display_name": {"readonly": True}, } _attribute_map = { "recommendation": {"key": "recommendation", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "applyResult", "type": "str"}, "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, "type_resource_type": {"key": "resource.type", "type": "str"}, "id_resource_id": {"key": "resource.id", "type": "str"}, "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, "type_principal_type": {"key": "principal.type", "type": "str"}, "id_principal_id": {"key": "principal.id", "type": "str"}, "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.principal_id_applied_by_principal_id = None self.principal_type_applied_by_principal_type = None self.principal_name_applied_by_principal_name = None self.user_principal_name_applied_by_user_principal_name = None self.principal_id_reviewed_by_principal_id = None self.principal_type_reviewed_by_principal_type = None self.principal_name_reviewed_by_principal_name = None self.user_principal_name_reviewed_by_user_principal_name = None self.type_resource_type: Optional[str] = None self.id_resource_id = None self.display_name_resource_display_name = None self.type_principal_type: Optional[str] = None self.id_principal_id = None self.display_name_principal_display_name = None class AccessReviewDecisionResource(_serialization.Model): """Target of the decision. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of resource. Required. "azureRole" :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType :ivar id: The id of resource associated with a decision record. :vartype id: str :ivar display_name: The display name of resource associated with a decision record. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): """Service Principal Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar app_id: The appId for the service principal entity being reviewed. :vartype app_id: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "app_id": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "app_id": {"key": "appId", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "servicePrincipal" self.app_id = None class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar user_principal_name: The user principal name of the user whose access was reviewed. :vartype user_principal_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "user_principal_name": {"key": "userPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "user" self.user_principal_name = None class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Default Settings. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review default settings id. This is only going to be default. :vartype id: str :ivar name: The access review default settings name. This is always going to be Access Review Default Settings. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "properties.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_recurrence_range_type = type_properties_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type self.interval = interval class AccessReviewInstance(_serialization.Model): """Access Review Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review instance id. :vartype id: str :ivar name: The access review instance name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewInstanceListResult(_serialization.Model): """List of Access Review Instances. :ivar value: Access Review Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewInstanceProperties(_serialization.Model): """Access Review Instance properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "status": {"key": "status", "type": "str"}, "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewReviewer(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of the reviewer(user/servicePrincipal). :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewerType """ _validation = { "principal_type": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: The id of the reviewer(user/servicePrincipal). :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.principal_type = None class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Schedule Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review schedule definition id. :vartype id: str :ivar name: The access review schedule definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_properties_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_properties_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": { "key": "properties.settings.justificationRequiredOnApproval", "type": "bool", }, "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": { "key": "properties.settings.recommendationLookBackDuration", "type": "duration", }, "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, "type_properties_settings_recurrence_range_type": { "key": "properties.settings.recurrence.range.type", "type": "str", }, "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_settings_recurrence_pattern_type": { "key": "properties.settings.recurrence.pattern.type", "type": "str", }, "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type_properties_created_by_principal_type": { "key": "properties.createdBy.principalType", "type": "str", }, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_settings_recurrence_range_type: Optional[ Union[str, "_models.AccessReviewRecurrenceRangeType"] ] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_properties_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_properties_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleDefinitionListResult(_serialization.Model): """List of Access Review Schedule Definitions. :ivar value: Access Review Schedule Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Schedule Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "scope.resourceId", "type": "str"}, "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, "assignment_state": {"key": "scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_settings_recurrence_range_type = type_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Settings of an Access Review. :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _attribute_map = { "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, "interval": {"key": "recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_recurrence_range_type = type_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_recurrence_pattern_type = type_recurrence_pattern_type self.interval = interval class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
0.815306
0.203668
from ._models_py3 import AccessReviewContactedReviewer from ._models_py3 import AccessReviewContactedReviewerListResult from ._models_py3 import AccessReviewDecision from ._models_py3 import AccessReviewDecisionIdentity from ._models_py3 import AccessReviewDecisionListResult from ._models_py3 import AccessReviewDecisionProperties from ._models_py3 import AccessReviewDecisionResource from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity from ._models_py3 import AccessReviewDecisionUserIdentity from ._models_py3 import AccessReviewDefaultSettings from ._models_py3 import AccessReviewInstance from ._models_py3 import AccessReviewInstanceListResult from ._models_py3 import AccessReviewInstanceProperties from ._models_py3 import AccessReviewReviewer from ._models_py3 import AccessReviewScheduleDefinition from ._models_py3 import AccessReviewScheduleDefinitionListResult from ._models_py3 import AccessReviewScheduleDefinitionProperties from ._models_py3 import AccessReviewScheduleSettings from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorDefinitionProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._authorization_management_client_enums import AccessRecommendationType from ._authorization_management_client_enums import AccessReviewActorIdentityType from ._authorization_management_client_enums import AccessReviewApplyResult from ._authorization_management_client_enums import AccessReviewInstanceReviewersType from ._authorization_management_client_enums import AccessReviewInstanceStatus from ._authorization_management_client_enums import AccessReviewRecurrencePatternType from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType from ._authorization_management_client_enums import AccessReviewResult from ._authorization_management_client_enums import AccessReviewReviewerType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus from ._authorization_management_client_enums import AccessReviewScopeAssignmentState from ._authorization_management_client_enums import AccessReviewScopePrincipalType from ._authorization_management_client_enums import DecisionResourceType from ._authorization_management_client_enums import DecisionTargetType from ._authorization_management_client_enums import DefaultDecisionType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccessReviewContactedReviewer", "AccessReviewContactedReviewerListResult", "AccessReviewDecision", "AccessReviewDecisionIdentity", "AccessReviewDecisionListResult", "AccessReviewDecisionProperties", "AccessReviewDecisionResource", "AccessReviewDecisionServicePrincipalIdentity", "AccessReviewDecisionUserIdentity", "AccessReviewDefaultSettings", "AccessReviewInstance", "AccessReviewInstanceListResult", "AccessReviewInstanceProperties", "AccessReviewReviewer", "AccessReviewScheduleDefinition", "AccessReviewScheduleDefinitionListResult", "AccessReviewScheduleDefinitionProperties", "AccessReviewScheduleSettings", "ErrorDefinition", "ErrorDefinitionProperties", "Operation", "OperationDisplay", "OperationListResult", "AccessRecommendationType", "AccessReviewActorIdentityType", "AccessReviewApplyResult", "AccessReviewInstanceReviewersType", "AccessReviewInstanceStatus", "AccessReviewRecurrencePatternType", "AccessReviewRecurrenceRangeType", "AccessReviewResult", "AccessReviewReviewerType", "AccessReviewScheduleDefinitionReviewersType", "AccessReviewScheduleDefinitionStatus", "AccessReviewScopeAssignmentState", "AccessReviewScopePrincipalType", "DecisionResourceType", "DecisionTargetType", "DefaultDecisionType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py
__init__.py
from ._models_py3 import AccessReviewContactedReviewer from ._models_py3 import AccessReviewContactedReviewerListResult from ._models_py3 import AccessReviewDecision from ._models_py3 import AccessReviewDecisionIdentity from ._models_py3 import AccessReviewDecisionListResult from ._models_py3 import AccessReviewDecisionProperties from ._models_py3 import AccessReviewDecisionResource from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity from ._models_py3 import AccessReviewDecisionUserIdentity from ._models_py3 import AccessReviewDefaultSettings from ._models_py3 import AccessReviewInstance from ._models_py3 import AccessReviewInstanceListResult from ._models_py3 import AccessReviewInstanceProperties from ._models_py3 import AccessReviewReviewer from ._models_py3 import AccessReviewScheduleDefinition from ._models_py3 import AccessReviewScheduleDefinitionListResult from ._models_py3 import AccessReviewScheduleDefinitionProperties from ._models_py3 import AccessReviewScheduleSettings from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorDefinitionProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._authorization_management_client_enums import AccessRecommendationType from ._authorization_management_client_enums import AccessReviewActorIdentityType from ._authorization_management_client_enums import AccessReviewApplyResult from ._authorization_management_client_enums import AccessReviewInstanceReviewersType from ._authorization_management_client_enums import AccessReviewInstanceStatus from ._authorization_management_client_enums import AccessReviewRecurrencePatternType from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType from ._authorization_management_client_enums import AccessReviewResult from ._authorization_management_client_enums import AccessReviewReviewerType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus from ._authorization_management_client_enums import AccessReviewScopeAssignmentState from ._authorization_management_client_enums import AccessReviewScopePrincipalType from ._authorization_management_client_enums import DecisionResourceType from ._authorization_management_client_enums import DecisionTargetType from ._authorization_management_client_enums import DefaultDecisionType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccessReviewContactedReviewer", "AccessReviewContactedReviewerListResult", "AccessReviewDecision", "AccessReviewDecisionIdentity", "AccessReviewDecisionListResult", "AccessReviewDecisionProperties", "AccessReviewDecisionResource", "AccessReviewDecisionServicePrincipalIdentity", "AccessReviewDecisionUserIdentity", "AccessReviewDefaultSettings", "AccessReviewInstance", "AccessReviewInstanceListResult", "AccessReviewInstanceProperties", "AccessReviewReviewer", "AccessReviewScheduleDefinition", "AccessReviewScheduleDefinitionListResult", "AccessReviewScheduleDefinitionProperties", "AccessReviewScheduleSettings", "ErrorDefinition", "ErrorDefinitionProperties", "Operation", "OperationDisplay", "OperationListResult", "AccessRecommendationType", "AccessReviewActorIdentityType", "AccessReviewApplyResult", "AccessReviewInstanceReviewersType", "AccessReviewInstanceStatus", "AccessReviewRecurrencePatternType", "AccessReviewRecurrenceRangeType", "AccessReviewResult", "AccessReviewReviewerType", "AccessReviewScheduleDefinitionReviewersType", "AccessReviewScheduleDefinitionStatus", "AccessReviewScopeAssignmentState", "AccessReviewScopePrincipalType", "DecisionResourceType", "DecisionTargetType", "DefaultDecisionType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.371023
0.078961
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AlertConfigurationsOperations, AlertDefinitionsOperations, AlertIncidentsOperations, AlertOperationOperations, AlertsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertsOperations :ivar alert_configurations: AlertConfigurationsOperations operations :vartype alert_configurations: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertConfigurationsOperations :ivar alert_definitions: AlertDefinitionsOperations operations :vartype alert_definitions: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertDefinitionsOperations :ivar alert_incidents: AlertIncidentsOperations operations :vartype alert_incidents: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertIncidentsOperations :ivar alert_operation: AlertOperationOperations operations :vartype alert_operation: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.alerts = AlertsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_configurations = AlertConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_definitions = AlertDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_incidents = AlertIncidentsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_operation = AlertOperationOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AlertConfigurationsOperations, AlertDefinitionsOperations, AlertIncidentsOperations, AlertOperationOperations, AlertsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertsOperations :ivar alert_configurations: AlertConfigurationsOperations operations :vartype alert_configurations: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertConfigurationsOperations :ivar alert_definitions: AlertDefinitionsOperations operations :vartype alert_definitions: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertDefinitionsOperations :ivar alert_incidents: AlertIncidentsOperations operations :vartype alert_incidents: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertIncidentsOperations :ivar alert_operation: AlertOperationOperations operations :vartype alert_operation: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.alerts = AlertsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_configurations = AlertConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_definitions = AlertDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_incidents = AlertIncidentsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_operation = AlertOperationOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.824321
0.101012
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.821008
0.082254
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section 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, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_refresh_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_refresh_all_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AlertsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: """Get the specified alert. :param scope: The scope of the alert. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.Alert, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Alert") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_initial.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } @distributed_trace def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: """Refresh an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._refresh_initial( scope=scope, alert_id=alert_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_all_request( scope=scope, api_version=api_version, template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} @distributed_trace def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: """Refresh all alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py
_alerts_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section 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, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_refresh_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_refresh_all_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AlertsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: """Get the specified alert. :param scope: The scope of the alert. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.Alert, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Alert") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_initial.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } @distributed_trace def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: """Refresh an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._refresh_initial( scope=scope, alert_id=alert_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_all_request( scope=scope, api_version=api_version, template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} @distributed_trace def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: """Refresh all alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"}
0.771801
0.084531
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertConfigurationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: """Get the specified alert configuration. :param scope: The scope of the alert configuration. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.AlertConfiguration, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AlertConfiguration") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py
_alert_configurations_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertConfigurationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: """Get the specified alert configuration. :param scope: The scope of the alert configuration. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.AlertConfiguration, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AlertConfiguration") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"}
0.825871
0.068756
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertDefinitionId": _SERIALIZER.url("alert_definition_id", alert_definition_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: """Get the specified alert definition. :param scope: The scope of the alert definition. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py
_alert_definitions_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertDefinitionId": _SERIALIZER.url("alert_definition_id", alert_definition_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: """Get the specified alert definition. :param scope: The scope of the alert definition. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"}
0.817756
0.071429
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_remediate_request(scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AlertIncidentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: """Get the specified alert incident. :param scope: The scope of the alert incident. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertIncident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" } @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" } @distributed_trace def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any ) -> None: """Remediate an alert incident. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) remediate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py
_alert_incidents_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_remediate_request(scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AlertIncidentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: """Get the specified alert incident. :param scope: The scope of the alert incident. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertIncident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" } @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" } @distributed_trace def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any ) -> None: """Remediate an alert incident. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) remediate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" }
0.759493
0.089177
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, operation_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertOperationOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: """Get the specified alert operation. :param scope: The scope of the alert operation. Required. :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py
_alert_operation_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, operation_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class AlertOperationOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: """Get the specified alert operation. :param scope: The scope of the alert operation. Required. :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"}
0.870046
0.074467
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AlertConfigurationsOperations, AlertDefinitionsOperations, AlertIncidentsOperations, AlertOperationOperations, AlertsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertsOperations :ivar alert_configurations: AlertConfigurationsOperations operations :vartype alert_configurations: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertConfigurationsOperations :ivar alert_definitions: AlertDefinitionsOperations operations :vartype alert_definitions: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertDefinitionsOperations :ivar alert_incidents: AlertIncidentsOperations operations :vartype alert_incidents: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertIncidentsOperations :ivar alert_operation: AlertOperationOperations operations :vartype alert_operation: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.alerts = AlertsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_configurations = AlertConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_definitions = AlertDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_incidents = AlertIncidentsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_operation = AlertOperationOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AlertConfigurationsOperations, AlertDefinitionsOperations, AlertIncidentsOperations, AlertOperationOperations, AlertsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertsOperations :ivar alert_configurations: AlertConfigurationsOperations operations :vartype alert_configurations: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertConfigurationsOperations :ivar alert_definitions: AlertDefinitionsOperations operations :vartype alert_definitions: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertDefinitionsOperations :ivar alert_incidents: AlertIncidentsOperations operations :vartype alert_incidents: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertIncidentsOperations :ivar alert_operation: AlertOperationOperations operations :vartype alert_operation: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.alerts = AlertsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_configurations = AlertConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_definitions = AlertDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_incidents = AlertIncidentsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) self.alert_operation = AlertOperationOperations( self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.820901
0.106412
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-08-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.826467
0.082994
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._alerts_operations import ( build_get_request, build_list_for_scope_request, build_refresh_all_request, build_refresh_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: """Get the specified alert. :param scope: The scope of the alert. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.Alert, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Alert") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_initial.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } @distributed_trace_async async def begin_refresh( self, scope: str, alert_id: str, **kwargs: Any ) -> AsyncLROPoller[_models.AlertOperationResult]: """Refresh an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._refresh_initial( scope=scope, alert_id=alert_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_all_request( scope=scope, api_version=api_version, template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} @distributed_trace_async async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_models.AlertOperationResult]: """Refresh all alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py
_alerts_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._alerts_operations import ( build_get_request, build_list_for_scope_request, build_refresh_all_request, build_refresh_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: """Get the specified alert. :param scope: The scope of the alert. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.Alert, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any ) -> None: """Update an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Alert") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_initial.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } @distributed_trace_async async def begin_refresh( self, scope: str, alert_id: str, **kwargs: Any ) -> AsyncLROPoller[_models.AlertOperationResult]: """Refresh an alert. :param scope: The scope of the alert. Required. :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._refresh_initial( scope=scope, alert_id=alert_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" } async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_refresh_all_request( scope=scope, api_version=api_version, template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} @distributed_trace_async async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_models.AlertOperationResult]: """Refresh all alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"}
0.885396
0.072999
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_configurations_operations import ( build_get_request, build_list_for_scope_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertConfigurationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: """Get the specified alert configuration. :param scope: The scope of the alert configuration. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.AlertConfiguration, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AlertConfiguration") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py
_alert_configurations_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_configurations_operations import ( build_get_request, build_list_for_scope_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertConfigurationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: """Get the specified alert configuration. :param scope: The scope of the alert configuration. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: _models.AlertConfiguration, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any ) -> None: """Update an alert configuration. :param scope: The scope of the alert configuration. Required. :type scope: str :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AlertConfiguration") request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"}
0.897905
0.087019
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_definitions_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: """Get the specified alert definition. :param scope: The scope of the alert definition. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py
_alert_definitions_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_definitions_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: """Get the specified alert definition. :param scope: The scope of the alert definition. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"}
0.871037
0.086246
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_incidents_operations import ( build_get_request, build_list_for_scope_request, build_remediate_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertIncidentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: """Get the specified alert incident. :param scope: The scope of the alert incident. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertIncident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" } @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterable["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" } @distributed_trace_async async def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any ) -> None: """Remediate an alert incident. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) remediate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py
_alert_incidents_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_incidents_operations import ( build_get_request, build_list_for_scope_request, build_remediate_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertIncidentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: """Get the specified alert incident. :param scope: The scope of the alert incident. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertIncident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" } @distributed_trace def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterable["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" } @distributed_trace_async async def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any ) -> None: """Remediate an alert incident. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) remediate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" }
0.875135
0.080755
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_operation_operations import build_get_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertOperationOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: """Get the specified alert operation. :param scope: The scope of the alert operation. Required. :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py
_alert_operation_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_operation_operations import build_get_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertOperationOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: """Get the specified alert operation. :param scope: The scope of the alert operation. Required. :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") ) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AlertOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"}
0.893181
0.082365
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class Alert(_serialization.Model): # pylint: disable=too-many-instance-attributes """The alert. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert ID. :vartype id: str :ivar name: The alert name. :vartype name: str :ivar type: The alert type. :vartype type: str :ivar scope: The alert scope. :vartype scope: str :ivar is_active: False by default; true if the alert is active. :vartype is_active: bool :ivar incident_count: The number of generated incidents of the alert. :vartype incident_count: int :ivar last_modified_date_time: The date time when the alert configuration was updated or new incidents were generated. :vartype last_modified_date_time: ~datetime.datetime :ivar last_scanned_date_time: The date time when the alert was last scanned. :vartype last_scanned_date_time: ~datetime.datetime :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar alert_incidents: The alert incidents. :vartype alert_incidents: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :ivar alert_configuration: The alert configuration. :vartype alert_configuration: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "incident_count": {"readonly": True}, "last_modified_date_time": {"readonly": True}, "last_scanned_date_time": {"readonly": True}, "alert_definition": {"readonly": True}, "alert_incidents": {"readonly": True}, "alert_configuration": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "is_active": {"key": "properties.isActive", "type": "bool"}, "incident_count": {"key": "properties.incidentCount", "type": "int"}, "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, "last_scanned_date_time": {"key": "properties.lastScannedDateTime", "type": "iso-8601"}, "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, "alert_incidents": {"key": "properties.alertIncidents", "type": "[AlertIncident]"}, "alert_configuration": {"key": "properties.alertConfiguration", "type": "AlertConfiguration"}, } def __init__(self, *, is_active: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_active: False by default; true if the alert is active. :paramtype is_active: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.is_active = is_active self.incident_count = None self.last_modified_date_time = None self.last_scanned_date_time = None self.alert_definition = None self.alert_incidents = None self.alert_configuration = None class AlertConfiguration(_serialization.Model): """Alert configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert configuration ID. :vartype id: str :ivar name: The alert configuration name. :vartype name: str :ivar type: The alert configuration type. :vartype type: str :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "alert_definition_id": {"key": "properties.alertDefinitionId", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "properties.alertConfigurationType", "type": "str"}, "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.alert_definition_id = None self.scope = None self.is_enabled = is_enabled self.alert_configuration_type: Optional[str] = None self.alert_definition = None class AlertConfigurationListResult(_serialization.Model): """Alert configuration list operation result. :ivar value: Alert configuration list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertConfiguration]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertConfiguration"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert configuration list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertConfigurationProperties(_serialization.Model): """Alert configuration properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureRolesAssignedOutsidePimAlertConfigurationProperties, DuplicateRoleCreatedAlertConfigurationProperties, TooManyOwnersAssignedToResourceAlertConfigurationProperties, TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } _subtype_map = { "alert_configuration_type": { "AzureRolesAssignedOutsidePimAlertConfiguration": "AzureRolesAssignedOutsidePimAlertConfigurationProperties", "DuplicateRoleCreatedAlertConfiguration": "DuplicateRoleCreatedAlertConfigurationProperties", "TooManyOwnersAssignedToResourceAlertConfiguration": "TooManyOwnersAssignedToResourceAlertConfigurationProperties", "TooManyPermanentOwnersAssignedToResourceAlertConfiguration": "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", } } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(**kwargs) self.alert_definition_id = None self.scope = None self.is_enabled = is_enabled self.alert_configuration_type: Optional[str] = None self.alert_definition = None class AlertDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Alert definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert definition ID. :vartype id: str :ivar name: The alert definition name. :vartype name: str :ivar type: The alert definition type. :vartype type: str :ivar display_name: The alert display name. :vartype display_name: str :ivar scope: The alert scope. :vartype scope: str :ivar description: The alert description. :vartype description: str :ivar severity_level: Severity level of the alert. Known values are: "Low", "Medium", and "High". :vartype severity_level: str or ~azure.mgmt.authorization.v2022_08_01_preview.models.SeverityLevel :ivar security_impact: Security impact of the alert. :vartype security_impact: str :ivar mitigation_steps: The methods to mitigate the alert. :vartype mitigation_steps: str :ivar how_to_prevent: The ways to prevent the alert. :vartype how_to_prevent: str :ivar is_remediatable: True if the alert can be remediated; false, otherwise. :vartype is_remediatable: bool :ivar is_configurable: True if the alert configuration can be configured; false, otherwise. :vartype is_configurable: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "display_name": {"readonly": True}, "scope": {"readonly": True}, "description": {"readonly": True}, "severity_level": {"readonly": True}, "security_impact": {"readonly": True}, "mitigation_steps": {"readonly": True}, "how_to_prevent": {"readonly": True}, "is_remediatable": {"readonly": True}, "is_configurable": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "severity_level": {"key": "properties.severityLevel", "type": "str"}, "security_impact": {"key": "properties.securityImpact", "type": "str"}, "mitigation_steps": {"key": "properties.mitigationSteps", "type": "str"}, "how_to_prevent": {"key": "properties.howToPrevent", "type": "str"}, "is_remediatable": {"key": "properties.isRemediatable", "type": "bool"}, "is_configurable": {"key": "properties.isConfigurable", "type": "bool"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = None self.scope = None self.description = None self.severity_level = None self.security_impact = None self.mitigation_steps = None self.how_to_prevent = None self.is_remediatable = None self.is_configurable = None class AlertDefinitionListResult(_serialization.Model): """Alert definition list operation result. :ivar value: Alert definition list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertIncident(_serialization.Model): """Alert incident. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert incident ID. :vartype id: str :ivar name: The alert incident name. :vartype name: str :ivar type: The alert incident type. :vartype type: str :ivar alert_incident_type: The alert incident type. :vartype alert_incident_type: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "alert_incident_type": {"key": "properties.alertIncidentType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.alert_incident_type: Optional[str] = None class AlertIncidentListResult(_serialization.Model): """Alert incident list operation result. :ivar value: Alert incident list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertIncident]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertIncident"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert incident list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertIncidentProperties(_serialization.Model): """Alert incident properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureRolesAssignedOutsidePimAlertIncidentProperties, DuplicateRoleCreatedAlertIncidentProperties, TooManyOwnersAssignedToResourceAlertIncidentProperties, TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str """ _validation = { "alert_incident_type": {"required": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, } _subtype_map = { "alert_incident_type": { "AzureRolesAssignedOutsidePimAlertIncident": "AzureRolesAssignedOutsidePimAlertIncidentProperties", "DuplicateRoleCreatedAlertIncident": "DuplicateRoleCreatedAlertIncidentProperties", "TooManyOwnersAssignedToResourceAlertIncident": "TooManyOwnersAssignedToResourceAlertIncidentProperties", "TooManyPermanentOwnersAssignedToResourceAlertIncident": "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: Optional[str] = None class AlertListResult(_serialization.Model): """Alert list operation result. :ivar value: Alert list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Alert]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Alert"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertOperationResult(_serialization.Model): """Alert operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The id of the alert operation. :vartype id: str :ivar status: The status of the alert operation. :vartype status: str :ivar status_detail: The status detail of the alert operation. :vartype status_detail: str :ivar created_date_time: The created date of the alert operation. :vartype created_date_time: ~datetime.datetime :ivar last_action_date_time: The last action date of the alert operation. :vartype last_action_date_time: ~datetime.datetime :ivar resource_location: The location of the alert associated with the operation. :vartype resource_location: str """ _validation = { "id": {"readonly": True}, "status": {"readonly": True}, "status_detail": {"readonly": True}, "created_date_time": {"readonly": True}, "last_action_date_time": {"readonly": True}, "resource_location": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "status": {"key": "status", "type": "str"}, "status_detail": {"key": "statusDetail", "type": "str"}, "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, "last_action_date_time": {"key": "lastActionDateTime", "type": "iso-8601"}, "resource_location": {"key": "resourceLocation", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.status = None self.status_detail = None self.created_date_time = None self.last_action_date_time = None self.resource_location = None class AzureRolesAssignedOutsidePimAlertConfigurationProperties(AlertConfigurationProperties): """The Azure roles assigned outside PIM alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "AzureRolesAssignedOutsidePimAlertConfiguration" class AzureRolesAssignedOutsidePimAlertIncidentProperties( AlertIncidentProperties ): # pylint: disable=too-many-instance-attributes """Azure roles assigned outside PIM alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_display_name: The assignee display name. :vartype assignee_display_name: str :ivar assignee_user_principal_name: The assignee user principal name. :vartype assignee_user_principal_name: str :ivar assignee_id: The assignee ID. :vartype assignee_id: str :ivar role_display_name: The role display name. :vartype role_display_name: str :ivar role_template_id: The role template ID. :vartype role_template_id: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar assignment_activated_date: The date the assignment was activated. :vartype assignment_activated_date: ~datetime.datetime :ivar requestor_id: The requestor ID. :vartype requestor_id: str :ivar requestor_display_name: The requestor display name. :vartype requestor_display_name: str :ivar requestor_user_principal_name: The requestor user principal name. :vartype requestor_user_principal_name: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_display_name": {"readonly": True}, "assignee_user_principal_name": {"readonly": True}, "assignee_id": {"readonly": True}, "role_display_name": {"readonly": True}, "role_template_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "assignment_activated_date": {"readonly": True}, "requestor_id": {"readonly": True}, "requestor_display_name": {"readonly": True}, "requestor_user_principal_name": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_display_name": {"key": "assigneeDisplayName", "type": "str"}, "assignee_user_principal_name": {"key": "assigneeUserPrincipalName", "type": "str"}, "assignee_id": {"key": "assigneeId", "type": "str"}, "role_display_name": {"key": "roleDisplayName", "type": "str"}, "role_template_id": {"key": "roleTemplateId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "assignment_activated_date": {"key": "assignmentActivatedDate", "type": "iso-8601"}, "requestor_id": {"key": "requestorId", "type": "str"}, "requestor_display_name": {"key": "requestorDisplayName", "type": "str"}, "requestor_user_principal_name": {"key": "requestorUserPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "AzureRolesAssignedOutsidePimAlertIncident" self.assignee_display_name = None self.assignee_user_principal_name = None self.assignee_id = None self.role_display_name = None self.role_template_id = None self.role_definition_id = None self.assignment_activated_date = None self.requestor_id = None self.requestor_display_name = None self.requestor_user_principal_name = None class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :vartype code: str :ivar message: A message describing the error, intended to be suitable for display in a user interface. :vartype message: str """ _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :paramtype code: str :keyword message: A message describing the error, intended to be suitable for display in a user interface. :paramtype message: str """ super().__init__(**kwargs) self.code = code self.message = message class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): """The duplicate role created alert configuration. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "DuplicateRoleCreatedAlertConfiguration" class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): """Duplicate role created alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar role_name: The role name. :vartype role_name: str :ivar duplicate_roles: The duplicate roles. :vartype duplicate_roles: str :ivar reason: The reason for the incident. :vartype reason: str """ _validation = { "alert_incident_type": {"required": True}, "role_name": {"readonly": True}, "duplicate_roles": {"readonly": True}, "reason": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "role_name": {"key": "roleName", "type": "str"}, "duplicate_roles": {"key": "duplicateRoles", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "DuplicateRoleCreatedAlertIncident" self.role_name = None self.duplicate_roles = None self.reason = None class TooManyOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): """Too many owners assigned to resource alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar threshold_number_of_owners: The threshold number of owners. :vartype threshold_number_of_owners: int :ivar threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of owners out of all role members. :vartype threshold_percentage_of_owners_out_of_all_role_members: int """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, "threshold_number_of_owners": {"key": "thresholdNumberOfOwners", "type": "int"}, "threshold_percentage_of_owners_out_of_all_role_members": { "key": "thresholdPercentageOfOwnersOutOfAllRoleMembers", "type": "int", }, } def __init__( self, *, is_enabled: Optional[bool] = None, threshold_number_of_owners: Optional[int] = None, threshold_percentage_of_owners_out_of_all_role_members: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool :keyword threshold_number_of_owners: The threshold number of owners. :paramtype threshold_number_of_owners: int :keyword threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of owners out of all role members. :paramtype threshold_percentage_of_owners_out_of_all_role_members: int """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "TooManyOwnersAssignedToResourceAlertConfiguration" self.threshold_number_of_owners = threshold_number_of_owners self.threshold_percentage_of_owners_out_of_all_role_members = ( threshold_percentage_of_owners_out_of_all_role_members ) class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): """Too many owners assigned to resource alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_name: The assignee name. :vartype assignee_name: str :ivar assignee_type: The assignee type. :vartype assignee_type: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_name": {"readonly": True}, "assignee_type": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_name": {"key": "assigneeName", "type": "str"}, "assignee_type": {"key": "assigneeType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "TooManyOwnersAssignedToResourceAlertIncident" self.assignee_name = None self.assignee_type = None class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): """Too many permanent owners assigned to resource alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar threshold_number_of_permanent_owners: The threshold number of permanent owners. :vartype threshold_number_of_permanent_owners: int :ivar threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of permanent owners out of all owners. :vartype threshold_percentage_of_permanent_owners_out_of_all_owners: int """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, "threshold_number_of_permanent_owners": {"key": "thresholdNumberOfPermanentOwners", "type": "int"}, "threshold_percentage_of_permanent_owners_out_of_all_owners": { "key": "thresholdPercentageOfPermanentOwnersOutOfAllOwners", "type": "int", }, } def __init__( self, *, is_enabled: Optional[bool] = None, threshold_number_of_permanent_owners: Optional[int] = None, threshold_percentage_of_permanent_owners_out_of_all_owners: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool :keyword threshold_number_of_permanent_owners: The threshold number of permanent owners. :paramtype threshold_number_of_permanent_owners: int :keyword threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of permanent owners out of all owners. :paramtype threshold_percentage_of_permanent_owners_out_of_all_owners: int """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "TooManyPermanentOwnersAssignedToResourceAlertConfiguration" self.threshold_number_of_permanent_owners = threshold_number_of_permanent_owners self.threshold_percentage_of_permanent_owners_out_of_all_owners = ( threshold_percentage_of_permanent_owners_out_of_all_owners ) class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): """Too many permanent owners assigned to resource alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_name: The assignee name. :vartype assignee_name: str :ivar assignee_type: The assignee type. :vartype assignee_type: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_name": {"readonly": True}, "assignee_type": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_name": {"key": "assigneeName", "type": "str"}, "assignee_type": {"key": "assigneeType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "TooManyPermanentOwnersAssignedToResourceAlertIncident" self.assignee_name = None self.assignee_type = None
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py
_models_py3.py
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class Alert(_serialization.Model): # pylint: disable=too-many-instance-attributes """The alert. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert ID. :vartype id: str :ivar name: The alert name. :vartype name: str :ivar type: The alert type. :vartype type: str :ivar scope: The alert scope. :vartype scope: str :ivar is_active: False by default; true if the alert is active. :vartype is_active: bool :ivar incident_count: The number of generated incidents of the alert. :vartype incident_count: int :ivar last_modified_date_time: The date time when the alert configuration was updated or new incidents were generated. :vartype last_modified_date_time: ~datetime.datetime :ivar last_scanned_date_time: The date time when the alert was last scanned. :vartype last_scanned_date_time: ~datetime.datetime :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar alert_incidents: The alert incidents. :vartype alert_incidents: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :ivar alert_configuration: The alert configuration. :vartype alert_configuration: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "incident_count": {"readonly": True}, "last_modified_date_time": {"readonly": True}, "last_scanned_date_time": {"readonly": True}, "alert_definition": {"readonly": True}, "alert_incidents": {"readonly": True}, "alert_configuration": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "is_active": {"key": "properties.isActive", "type": "bool"}, "incident_count": {"key": "properties.incidentCount", "type": "int"}, "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, "last_scanned_date_time": {"key": "properties.lastScannedDateTime", "type": "iso-8601"}, "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, "alert_incidents": {"key": "properties.alertIncidents", "type": "[AlertIncident]"}, "alert_configuration": {"key": "properties.alertConfiguration", "type": "AlertConfiguration"}, } def __init__(self, *, is_active: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_active: False by default; true if the alert is active. :paramtype is_active: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.is_active = is_active self.incident_count = None self.last_modified_date_time = None self.last_scanned_date_time = None self.alert_definition = None self.alert_incidents = None self.alert_configuration = None class AlertConfiguration(_serialization.Model): """Alert configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert configuration ID. :vartype id: str :ivar name: The alert configuration name. :vartype name: str :ivar type: The alert configuration type. :vartype type: str :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "alert_definition_id": {"key": "properties.alertDefinitionId", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "properties.alertConfigurationType", "type": "str"}, "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.alert_definition_id = None self.scope = None self.is_enabled = is_enabled self.alert_configuration_type: Optional[str] = None self.alert_definition = None class AlertConfigurationListResult(_serialization.Model): """Alert configuration list operation result. :ivar value: Alert configuration list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertConfiguration]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertConfiguration"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert configuration list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertConfigurationProperties(_serialization.Model): """Alert configuration properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureRolesAssignedOutsidePimAlertConfigurationProperties, DuplicateRoleCreatedAlertConfigurationProperties, TooManyOwnersAssignedToResourceAlertConfigurationProperties, TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } _subtype_map = { "alert_configuration_type": { "AzureRolesAssignedOutsidePimAlertConfiguration": "AzureRolesAssignedOutsidePimAlertConfigurationProperties", "DuplicateRoleCreatedAlertConfiguration": "DuplicateRoleCreatedAlertConfigurationProperties", "TooManyOwnersAssignedToResourceAlertConfiguration": "TooManyOwnersAssignedToResourceAlertConfigurationProperties", "TooManyPermanentOwnersAssignedToResourceAlertConfiguration": "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", } } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(**kwargs) self.alert_definition_id = None self.scope = None self.is_enabled = is_enabled self.alert_configuration_type: Optional[str] = None self.alert_definition = None class AlertDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Alert definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert definition ID. :vartype id: str :ivar name: The alert definition name. :vartype name: str :ivar type: The alert definition type. :vartype type: str :ivar display_name: The alert display name. :vartype display_name: str :ivar scope: The alert scope. :vartype scope: str :ivar description: The alert description. :vartype description: str :ivar severity_level: Severity level of the alert. Known values are: "Low", "Medium", and "High". :vartype severity_level: str or ~azure.mgmt.authorization.v2022_08_01_preview.models.SeverityLevel :ivar security_impact: Security impact of the alert. :vartype security_impact: str :ivar mitigation_steps: The methods to mitigate the alert. :vartype mitigation_steps: str :ivar how_to_prevent: The ways to prevent the alert. :vartype how_to_prevent: str :ivar is_remediatable: True if the alert can be remediated; false, otherwise. :vartype is_remediatable: bool :ivar is_configurable: True if the alert configuration can be configured; false, otherwise. :vartype is_configurable: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "display_name": {"readonly": True}, "scope": {"readonly": True}, "description": {"readonly": True}, "severity_level": {"readonly": True}, "security_impact": {"readonly": True}, "mitigation_steps": {"readonly": True}, "how_to_prevent": {"readonly": True}, "is_remediatable": {"readonly": True}, "is_configurable": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "severity_level": {"key": "properties.severityLevel", "type": "str"}, "security_impact": {"key": "properties.securityImpact", "type": "str"}, "mitigation_steps": {"key": "properties.mitigationSteps", "type": "str"}, "how_to_prevent": {"key": "properties.howToPrevent", "type": "str"}, "is_remediatable": {"key": "properties.isRemediatable", "type": "bool"}, "is_configurable": {"key": "properties.isConfigurable", "type": "bool"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = None self.scope = None self.description = None self.severity_level = None self.security_impact = None self.mitigation_steps = None self.how_to_prevent = None self.is_remediatable = None self.is_configurable = None class AlertDefinitionListResult(_serialization.Model): """Alert definition list operation result. :ivar value: Alert definition list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertIncident(_serialization.Model): """Alert incident. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The alert incident ID. :vartype id: str :ivar name: The alert incident name. :vartype name: str :ivar type: The alert incident type. :vartype type: str :ivar alert_incident_type: The alert incident type. :vartype alert_incident_type: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "alert_incident_type": {"key": "properties.alertIncidentType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.alert_incident_type: Optional[str] = None class AlertIncidentListResult(_serialization.Model): """Alert incident list operation result. :ivar value: Alert incident list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AlertIncident]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AlertIncident"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert incident list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertIncidentProperties(_serialization.Model): """Alert incident properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureRolesAssignedOutsidePimAlertIncidentProperties, DuplicateRoleCreatedAlertIncidentProperties, TooManyOwnersAssignedToResourceAlertIncidentProperties, TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str """ _validation = { "alert_incident_type": {"required": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, } _subtype_map = { "alert_incident_type": { "AzureRolesAssignedOutsidePimAlertIncident": "AzureRolesAssignedOutsidePimAlertIncidentProperties", "DuplicateRoleCreatedAlertIncident": "DuplicateRoleCreatedAlertIncidentProperties", "TooManyOwnersAssignedToResourceAlertIncident": "TooManyOwnersAssignedToResourceAlertIncidentProperties", "TooManyPermanentOwnersAssignedToResourceAlertIncident": "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: Optional[str] = None class AlertListResult(_serialization.Model): """Alert list operation result. :ivar value: Alert list. :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Alert]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Alert"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Alert list. :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AlertOperationResult(_serialization.Model): """Alert operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The id of the alert operation. :vartype id: str :ivar status: The status of the alert operation. :vartype status: str :ivar status_detail: The status detail of the alert operation. :vartype status_detail: str :ivar created_date_time: The created date of the alert operation. :vartype created_date_time: ~datetime.datetime :ivar last_action_date_time: The last action date of the alert operation. :vartype last_action_date_time: ~datetime.datetime :ivar resource_location: The location of the alert associated with the operation. :vartype resource_location: str """ _validation = { "id": {"readonly": True}, "status": {"readonly": True}, "status_detail": {"readonly": True}, "created_date_time": {"readonly": True}, "last_action_date_time": {"readonly": True}, "resource_location": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "status": {"key": "status", "type": "str"}, "status_detail": {"key": "statusDetail", "type": "str"}, "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, "last_action_date_time": {"key": "lastActionDateTime", "type": "iso-8601"}, "resource_location": {"key": "resourceLocation", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.status = None self.status_detail = None self.created_date_time = None self.last_action_date_time = None self.resource_location = None class AzureRolesAssignedOutsidePimAlertConfigurationProperties(AlertConfigurationProperties): """The Azure roles assigned outside PIM alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "AzureRolesAssignedOutsidePimAlertConfiguration" class AzureRolesAssignedOutsidePimAlertIncidentProperties( AlertIncidentProperties ): # pylint: disable=too-many-instance-attributes """Azure roles assigned outside PIM alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_display_name: The assignee display name. :vartype assignee_display_name: str :ivar assignee_user_principal_name: The assignee user principal name. :vartype assignee_user_principal_name: str :ivar assignee_id: The assignee ID. :vartype assignee_id: str :ivar role_display_name: The role display name. :vartype role_display_name: str :ivar role_template_id: The role template ID. :vartype role_template_id: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar assignment_activated_date: The date the assignment was activated. :vartype assignment_activated_date: ~datetime.datetime :ivar requestor_id: The requestor ID. :vartype requestor_id: str :ivar requestor_display_name: The requestor display name. :vartype requestor_display_name: str :ivar requestor_user_principal_name: The requestor user principal name. :vartype requestor_user_principal_name: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_display_name": {"readonly": True}, "assignee_user_principal_name": {"readonly": True}, "assignee_id": {"readonly": True}, "role_display_name": {"readonly": True}, "role_template_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "assignment_activated_date": {"readonly": True}, "requestor_id": {"readonly": True}, "requestor_display_name": {"readonly": True}, "requestor_user_principal_name": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_display_name": {"key": "assigneeDisplayName", "type": "str"}, "assignee_user_principal_name": {"key": "assigneeUserPrincipalName", "type": "str"}, "assignee_id": {"key": "assigneeId", "type": "str"}, "role_display_name": {"key": "roleDisplayName", "type": "str"}, "role_template_id": {"key": "roleTemplateId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "assignment_activated_date": {"key": "assignmentActivatedDate", "type": "iso-8601"}, "requestor_id": {"key": "requestorId", "type": "str"}, "requestor_display_name": {"key": "requestorDisplayName", "type": "str"}, "requestor_user_principal_name": {"key": "requestorUserPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "AzureRolesAssignedOutsidePimAlertIncident" self.assignee_display_name = None self.assignee_user_principal_name = None self.assignee_id = None self.role_display_name = None self.role_template_id = None self.role_definition_id = None self.assignment_activated_date = None self.requestor_id = None self.requestor_display_name = None self.requestor_user_principal_name = None class CloudErrorBody(_serialization.Model): """An error response from the service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :vartype code: str :ivar message: A message describing the error, intended to be suitable for display in a user interface. :vartype message: str """ _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. :paramtype code: str :keyword message: A message describing the error, intended to be suitable for display in a user interface. :paramtype message: str """ super().__init__(**kwargs) self.code = code self.message = message class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): """The duplicate role created alert configuration. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, } def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "DuplicateRoleCreatedAlertConfiguration" class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): """Duplicate role created alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar role_name: The role name. :vartype role_name: str :ivar duplicate_roles: The duplicate roles. :vartype duplicate_roles: str :ivar reason: The reason for the incident. :vartype reason: str """ _validation = { "alert_incident_type": {"required": True}, "role_name": {"readonly": True}, "duplicate_roles": {"readonly": True}, "reason": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "role_name": {"key": "roleName", "type": "str"}, "duplicate_roles": {"key": "duplicateRoles", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "DuplicateRoleCreatedAlertIncident" self.role_name = None self.duplicate_roles = None self.reason = None class TooManyOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): """Too many owners assigned to resource alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar threshold_number_of_owners: The threshold number of owners. :vartype threshold_number_of_owners: int :ivar threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of owners out of all role members. :vartype threshold_percentage_of_owners_out_of_all_role_members: int """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, "threshold_number_of_owners": {"key": "thresholdNumberOfOwners", "type": "int"}, "threshold_percentage_of_owners_out_of_all_role_members": { "key": "thresholdPercentageOfOwnersOutOfAllRoleMembers", "type": "int", }, } def __init__( self, *, is_enabled: Optional[bool] = None, threshold_number_of_owners: Optional[int] = None, threshold_percentage_of_owners_out_of_all_role_members: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool :keyword threshold_number_of_owners: The threshold number of owners. :paramtype threshold_number_of_owners: int :keyword threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of owners out of all role members. :paramtype threshold_percentage_of_owners_out_of_all_role_members: int """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "TooManyOwnersAssignedToResourceAlertConfiguration" self.threshold_number_of_owners = threshold_number_of_owners self.threshold_percentage_of_owners_out_of_all_role_members = ( threshold_percentage_of_owners_out_of_all_role_members ) class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): """Too many owners assigned to resource alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_name: The assignee name. :vartype assignee_name: str :ivar assignee_type: The assignee type. :vartype assignee_type: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_name": {"readonly": True}, "assignee_type": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_name": {"key": "assigneeName", "type": "str"}, "assignee_type": {"key": "assigneeType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "TooManyOwnersAssignedToResourceAlertIncident" self.assignee_name = None self.assignee_type = None class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): """Too many permanent owners assigned to resource alert configuration properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_definition_id: The alert definition ID. :vartype alert_definition_id: str :ivar scope: The alert scope. :vartype scope: str :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :vartype is_enabled: bool :ivar alert_configuration_type: The alert configuration type. Required. :vartype alert_configuration_type: str :ivar alert_definition: The alert definition. :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition :ivar threshold_number_of_permanent_owners: The threshold number of permanent owners. :vartype threshold_number_of_permanent_owners: int :ivar threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of permanent owners out of all owners. :vartype threshold_percentage_of_permanent_owners_out_of_all_owners: int """ _validation = { "alert_definition_id": {"readonly": True}, "scope": {"readonly": True}, "alert_configuration_type": {"required": True}, "alert_definition": {"readonly": True}, } _attribute_map = { "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, "scope": {"key": "scope", "type": "str"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, "threshold_number_of_permanent_owners": {"key": "thresholdNumberOfPermanentOwners", "type": "int"}, "threshold_percentage_of_permanent_owners_out_of_all_owners": { "key": "thresholdPercentageOfPermanentOwnersOutOfAllOwners", "type": "int", }, } def __init__( self, *, is_enabled: Optional[bool] = None, threshold_number_of_permanent_owners: Optional[int] = None, threshold_percentage_of_permanent_owners_out_of_all_owners: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the specific alert. :paramtype is_enabled: bool :keyword threshold_number_of_permanent_owners: The threshold number of permanent owners. :paramtype threshold_number_of_permanent_owners: int :keyword threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of permanent owners out of all owners. :paramtype threshold_percentage_of_permanent_owners_out_of_all_owners: int """ super().__init__(is_enabled=is_enabled, **kwargs) self.alert_configuration_type: str = "TooManyPermanentOwnersAssignedToResourceAlertConfiguration" self.threshold_number_of_permanent_owners = threshold_number_of_permanent_owners self.threshold_percentage_of_permanent_owners_out_of_all_owners = ( threshold_percentage_of_permanent_owners_out_of_all_owners ) class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): """Too many permanent owners assigned to resource alert incident properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar alert_incident_type: The alert incident type. Required. :vartype alert_incident_type: str :ivar assignee_name: The assignee name. :vartype assignee_name: str :ivar assignee_type: The assignee type. :vartype assignee_type: str """ _validation = { "alert_incident_type": {"required": True}, "assignee_name": {"readonly": True}, "assignee_type": {"readonly": True}, } _attribute_map = { "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, "assignee_name": {"key": "assigneeName", "type": "str"}, "assignee_type": {"key": "assigneeType", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.alert_incident_type: str = "TooManyPermanentOwnersAssignedToResourceAlertIncident" self.assignee_name = None self.assignee_type = None
0.873687
0.294621
from ._models_py3 import Alert from ._models_py3 import AlertConfiguration from ._models_py3 import AlertConfigurationListResult from ._models_py3 import AlertConfigurationProperties from ._models_py3 import AlertDefinition from ._models_py3 import AlertDefinitionListResult from ._models_py3 import AlertIncident from ._models_py3 import AlertIncidentListResult from ._models_py3 import AlertIncidentProperties from ._models_py3 import AlertListResult from ._models_py3 import AlertOperationResult from ._models_py3 import AzureRolesAssignedOutsidePimAlertConfigurationProperties from ._models_py3 import AzureRolesAssignedOutsidePimAlertIncidentProperties from ._models_py3 import CloudErrorBody from ._models_py3 import DuplicateRoleCreatedAlertConfigurationProperties from ._models_py3 import DuplicateRoleCreatedAlertIncidentProperties from ._models_py3 import TooManyOwnersAssignedToResourceAlertConfigurationProperties from ._models_py3 import TooManyOwnersAssignedToResourceAlertIncidentProperties from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties from ._authorization_management_client_enums import SeverityLevel from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Alert", "AlertConfiguration", "AlertConfigurationListResult", "AlertConfigurationProperties", "AlertDefinition", "AlertDefinitionListResult", "AlertIncident", "AlertIncidentListResult", "AlertIncidentProperties", "AlertListResult", "AlertOperationResult", "AzureRolesAssignedOutsidePimAlertConfigurationProperties", "AzureRolesAssignedOutsidePimAlertIncidentProperties", "CloudErrorBody", "DuplicateRoleCreatedAlertConfigurationProperties", "DuplicateRoleCreatedAlertIncidentProperties", "TooManyOwnersAssignedToResourceAlertConfigurationProperties", "TooManyOwnersAssignedToResourceAlertIncidentProperties", "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", "SeverityLevel", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_08_01_preview/models/__init__.py
__init__.py
from ._models_py3 import Alert from ._models_py3 import AlertConfiguration from ._models_py3 import AlertConfigurationListResult from ._models_py3 import AlertConfigurationProperties from ._models_py3 import AlertDefinition from ._models_py3 import AlertDefinitionListResult from ._models_py3 import AlertIncident from ._models_py3 import AlertIncidentListResult from ._models_py3 import AlertIncidentProperties from ._models_py3 import AlertListResult from ._models_py3 import AlertOperationResult from ._models_py3 import AzureRolesAssignedOutsidePimAlertConfigurationProperties from ._models_py3 import AzureRolesAssignedOutsidePimAlertIncidentProperties from ._models_py3 import CloudErrorBody from ._models_py3 import DuplicateRoleCreatedAlertConfigurationProperties from ._models_py3 import DuplicateRoleCreatedAlertIncidentProperties from ._models_py3 import TooManyOwnersAssignedToResourceAlertConfigurationProperties from ._models_py3 import TooManyOwnersAssignedToResourceAlertIncidentProperties from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties from ._authorization_management_client_enums import SeverityLevel from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Alert", "AlertConfiguration", "AlertConfigurationListResult", "AlertConfigurationProperties", "AlertDefinition", "AlertDefinitionListResult", "AlertIncident", "AlertIncidentListResult", "AlertIncidentProperties", "AlertListResult", "AlertOperationResult", "AzureRolesAssignedOutsidePimAlertConfigurationProperties", "AzureRolesAssignedOutsidePimAlertIncidentProperties", "CloudErrorBody", "DuplicateRoleCreatedAlertConfigurationProperties", "DuplicateRoleCreatedAlertIncidentProperties", "TooManyOwnersAssignedToResourceAlertConfigurationProperties", "TooManyOwnersAssignedToResourceAlertIncidentProperties", "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", "SeverityLevel", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.497803
0.040579
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.843734
0.098079
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.833257
0.087291
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_09_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py
_role_assignments_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_09_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
0.738292
0.083479
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.830972
0.103295
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.835618
0.089335
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_09_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload async def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py
_role_assignments_operations.py
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_09_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload async def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
0.879458
0.080973
from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignment(_serialization.Model): """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. All required parameters must be populated in order to send to Azure. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :ivar can_delegate: The delegation flag used for creating a role assignment. :vartype can_delegate: bool """ _validation = { "role_definition_id": {"required": True}, "principal_id": {"required": True}, } _attribute_map = { "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID used in the role assignment. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :keyword can_delegate: The delegation flag used for creating a role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "can_delegate": {"key": "canDelegate", "type": "bool"}, } def __init__( self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py
_models_py3.py
from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignment(_serialization.Model): """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. All required parameters must be populated in order to send to Azure. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :ivar can_delegate: The delegation flag used for creating a role assignment. :vartype can_delegate: bool """ _validation = { "role_definition_id": {"required": True}, "principal_id": {"required": True}, } _attribute_map = { "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID used in the role assignment. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType :keyword can_delegate: The delegation flag used for creating a role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "can_delegate": {"key": "canDelegate", "type": "bool"}, } def __init__( self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
0.905388
0.270926
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.843057
0.117193
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.838018
0.085213
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators" ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ClassicAdministratorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2015_06_01.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py
_classic_administrators_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators" ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ClassicAdministratorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2015_06_01.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"}
0.836588
0.078819
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.classic_administrators = ClassicAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize, "2015-06-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.830078
0.12416
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.837288
0.089296
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._classic_administrators_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ClassicAdministratorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2015_06_01.aio.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py
_classic_administrators_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._classic_administrators_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ClassicAdministratorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2015_06_01.aio.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"}
0.861217
0.092688
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ClassicAdministrator(_serialization.Model): """Classic Administrators. :ivar id: The ID of the administrator. :vartype id: str :ivar name: The name of the administrator. :vartype name: str :ivar type: The type of the administrator. :vartype type: str :ivar email_address: The email address of the administrator. :vartype email_address: str :ivar role: The role of the administrator. :vartype role: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "email_address": {"key": "properties.emailAddress", "type": "str"}, "role": {"key": "properties.role", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, email_address: Optional[str] = None, role: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The ID of the administrator. :paramtype id: str :keyword name: The name of the administrator. :paramtype name: str :keyword type: The type of the administrator. :paramtype type: str :keyword email_address: The email address of the administrator. :paramtype email_address: str :keyword role: The role of the administrator. :paramtype role: str """ super().__init__(**kwargs) self.id = id self.name = name self.type = type self.email_address = email_address self.role = role class ClassicAdministratorListResult(_serialization.Model): """ClassicAdministrator list result information. :ivar value: An array of administrators. :vartype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[ClassicAdministrator]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.ClassicAdministrator"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of administrators. :paramtype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ super().__init__(**kwargs) self.error = error
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py
_models_py3.py
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ClassicAdministrator(_serialization.Model): """Classic Administrators. :ivar id: The ID of the administrator. :vartype id: str :ivar name: The name of the administrator. :vartype name: str :ivar type: The type of the administrator. :vartype type: str :ivar email_address: The email address of the administrator. :vartype email_address: str :ivar role: The role of the administrator. :vartype role: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "email_address": {"key": "properties.emailAddress", "type": "str"}, "role": {"key": "properties.role", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, email_address: Optional[str] = None, role: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The ID of the administrator. :paramtype id: str :keyword name: The name of the administrator. :paramtype name: str :keyword type: The type of the administrator. :paramtype type: str :keyword email_address: The email address of the administrator. :paramtype email_address: str :keyword role: The role of the administrator. :paramtype role: str """ super().__init__(**kwargs) self.id = id self.name = name self.type = type self.email_address = email_address self.role = role class ClassicAdministratorListResult(_serialization.Model): """ClassicAdministrator list result information. :ivar value: An array of administrators. :vartype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[ClassicAdministrator]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.ClassicAdministrator"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of administrators. :paramtype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ super().__init__(**kwargs) self.error = error
0.909733
0.287724
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Request Approvals service provides the workflow for running request approvals on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalOperations :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval = RoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Request Approvals service provides the workflow for running request approvals on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalOperations :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval = RoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.773943
0.200167
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.820613
0.083928
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(approval_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py
_role_assignment_approval_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(approval_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
0.840799
0.086131
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(approval_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py
_role_assignment_approval_steps_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(approval_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
0.842459
0.085442
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_by_id_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_id( self, approval_id: str, stage_id: str, scope: str, **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def patch( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def put( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py
_scope_role_assignment_approval_step_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_by_id_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_id( self, approval_id: str, stage_id: str, scope: str, **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def patch( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def put( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" }
0.799403
0.073099
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py
_scope_role_assignment_approval_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
0.828766
0.091544
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_by_id_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def patch( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} @overload def put( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py
_role_assignment_approval_step_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_by_id_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload def patch( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} @overload def put( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"}
0.816991
0.067577
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py
_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
0.841793
0.078607
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py
_scope_role_assignment_approval_steps_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages" ) # pylint: disable=line-too-long path_format_arguments = { "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class ScopeRoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
0.843622
0.084909
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Request Approvals service provides the workflow for running request approvals on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval = RoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Request Approvals service provides the workflow for running request approvals on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval = RoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.788502
0.206414
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.826502
0.084833
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace_async async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py
_role_assignment_approval_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace_async async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
0.870088
0.119459
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_steps_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py
_role_assignment_approval_steps_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_steps_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
0.876845
0.099252
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_id( self, approval_id: str, stage_id: str, scope: str, **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def patch( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def put( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py
_scope_role_assignment_approval_step_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_id( self, approval_id: str, stage_id: str, scope: str, **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def patch( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def put( self, approval_id: str, stage_id: str, scope: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, approval_id: str, stage_id: str, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, approval_id: str, stage_id: str, scope: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param scope: The scope of the resource. Required. :type scope: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" }
0.898201
0.106133
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace_async async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py
_scope_role_assignment_approval_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentApproval"]: """Get role assignment approvals. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is performed. If $filter=asApprover() is provided, the returned list only includes all role assignment approvals that the calling user is assigned as an approver for. If $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} @distributed_trace_async async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApproval or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"}
0.856767
0.100084
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def patch( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} @overload async def put( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py
_role_assignment_approval_step_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_approval_step_operations import ( build_get_by_id_request, build_patch_request, build_put_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentApprovalStepOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_approval_step` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) request = build_get_by_id_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" } @overload async def patch( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_patch_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} @overload async def put( self, approval_id: str, stage_id: str, properties: _models.RoleAssignmentApprovalStepProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, approval_id: str, stage_id: str, properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], **kwargs: Any ) -> _models.RoleAssignmentApprovalStep: """Record a decision. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param stage_id: The id of the role assignment approval stage. Required. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. Is either a RoleAssignmentApprovalStepProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") request = build_put_request( approval_id=approval_id, stage_id=stage_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"}
0.903422
0.095013
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py
_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
0.870858
0.092033
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_steps_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py
_scope_role_assignment_approval_steps_operations.py
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_role_assignment_approval_steps_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeRoleAssignmentApprovalStepsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_role_assignment_approval_steps` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: """Get role assignment approval. :param approval_id: The id of the role assignment approval. Required. :type approval_id: str :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") ) cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) request = build_list_request( approval_id=approval_id, scope=scope, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"}
0.885483
0.104889
from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. Values include user|system|user,system. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. Values include user|system|user,system. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentApproval(_serialization.Model): """Role Assignment Approval. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment approval id. :vartype id: str :ivar name: The role assignment approval unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar stages: This is the collection of stages returned when one does an expand on it. :vartype stages: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "stages": {"key": "properties.stages", "type": "[RoleAssignmentApprovalStep]"}, } def __init__(self, *, stages: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: """ :keyword stages: This is the collection of stages returned when one does an expand on it. :paramtype stages: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.stages = stages class RoleAssignmentApprovalListResult(_serialization.Model): """List of role assignment approvals. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role Assignment Approval list. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentApproval]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignmentApproval"]] = None, **kwargs: Any) -> None: """ :keyword value: Role Assignment Approval list. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentApprovalStep(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment approval stage properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment approval stage id. :vartype id: str :ivar name: The role assignment approval stage name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the approval stage. :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Known values are: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", and "Escalated". :vartype status: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "assigned_to_me": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "assigned_to_me": {"key": "properties.assignedToMe", "type": "bool"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "review_result": {"key": "properties.reviewResult", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type": {"key": "properties.reviewedBy.principalType", "type": "str"}, "principal_name": {"key": "properties.reviewedBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.reviewedBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the approval stage. :paramtype display_name: str :keyword review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :paramtype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.assigned_to_me = None self.reviewed_date_time = None self.review_result = review_result self.justification = justification self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class RoleAssignmentApprovalStepListResult(_serialization.Model): """List of role assignment approval stage list. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role Assignment Approval Step list. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentApprovalStep]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: """ :keyword value: Role Assignment Approval Step list. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentApprovalStepProperties(_serialization.Model): """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the approval stage. :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Known values are: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", and "Escalated". :vartype status: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "assigned_to_me": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "assigned_to_me": {"key": "assignedToMe", "type": "bool"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "review_result": {"key": "reviewResult", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the approval stage. :paramtype display_name: str :keyword review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :paramtype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.assigned_to_me = None self.reviewed_date_time = None self.review_result = review_result self.justification = justification self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py
_models_py3.py
from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. Values include user|system|user,system. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. Values include user|system|user,system. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleAssignmentApproval(_serialization.Model): """Role Assignment Approval. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment approval id. :vartype id: str :ivar name: The role assignment approval unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar stages: This is the collection of stages returned when one does an expand on it. :vartype stages: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "stages": {"key": "properties.stages", "type": "[RoleAssignmentApprovalStep]"}, } def __init__(self, *, stages: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: """ :keyword stages: This is the collection of stages returned when one does an expand on it. :paramtype stages: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.stages = stages class RoleAssignmentApprovalListResult(_serialization.Model): """List of role assignment approvals. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role Assignment Approval list. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentApproval]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignmentApproval"]] = None, **kwargs: Any) -> None: """ :keyword value: Role Assignment Approval list. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentApprovalStep(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment approval stage properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment approval stage id. :vartype id: str :ivar name: The role assignment approval stage name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the approval stage. :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Known values are: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", and "Escalated". :vartype status: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "assigned_to_me": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "assigned_to_me": {"key": "properties.assignedToMe", "type": "bool"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "review_result": {"key": "properties.reviewResult", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type": {"key": "properties.reviewedBy.principalType", "type": "str"}, "principal_name": {"key": "properties.reviewedBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.reviewedBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the approval stage. :paramtype display_name: str :keyword review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :paramtype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.assigned_to_me = None self.reviewed_date_time = None self.review_result = review_result self.justification = justification self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class RoleAssignmentApprovalStepListResult(_serialization.Model): """List of role assignment approval stage list. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role Assignment Approval Step list. :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignmentApprovalStep]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: """ :keyword value: Role Assignment Approval Step list. :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleAssignmentApprovalStepProperties(_serialization.Model): """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the approval stage. :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Known values are: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", and "Escalated". :vartype status: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "assigned_to_me": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "assigned_to_me": {"key": "assignedToMe", "type": "bool"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "review_result": {"key": "reviewResult", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the approval stage. :paramtype display_name: str :keyword review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", and "NotReviewed". :paramtype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.assigned_to_me = None self.reviewed_date_time = None self.review_result = review_result self.justification = justification self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None
0.917117
0.334916
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.840619
0.103839
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.833291
0.088387
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{denyAssignmentId}") path_format_arguments = { "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class DenyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_07_01_preview.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get deny assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} @distributed_trace def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. Required. :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} @distributed_trace def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for subscription level deny assignments, or /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{denyAssignmentId}"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py
_deny_assignments_operations.py
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{denyAssignmentId}") path_format_arguments = { "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class DenyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_07_01_preview.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get deny assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} @distributed_trace def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. Required. :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} @distributed_trace def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for subscription level deny assignments, or /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{denyAssignmentId}"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"}
0.767864
0.076442
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.deny_assignments = DenyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client._send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() async def __aenter__(self) -> "AuthorizationManagementClient": await self._client.__aenter__() return self async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details)
0.828419
0.109182
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.835551
0.090534
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._deny_assignments_operations import ( build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DenyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get deny assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} @distributed_trace_async async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. Required. :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} @distributed_trace_async async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for subscription level deny assignments, or /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{denyAssignmentId}"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py
_deny_assignments_operations.py
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._deny_assignments_operations import ( build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DenyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_07_01_preview.aio.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get deny assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" } @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} @distributed_trace_async async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. :param scope: The scope of the deny assignment. Required. :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} @distributed_trace_async async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for subscription level deny assignments, or /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DenyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{denyAssignmentId}"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny assignments at or above the scope. Use $filter=denyAssignmentName eq '{name}' to search deny assignments by name at specified scope. Use $filter=principalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. Use $filter=gdprExportPrincipalId eq '{id}' to return all deny assignments at, above and below the scope for the specified principal. This filter is different from the principalId filter as it returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") ) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"}
0.887156
0.096535
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deny Assignment. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The deny assignment ID. :vartype id: str :ivar name: The deny assignment name. :vartype name: str :ivar type: The deny assignment type. :vartype type: str :ivar deny_assignment_name: The display name of the deny assignment. :vartype deny_assignment_name: str :ivar description: The description of the deny assignment. :vartype description: str :ivar permissions: An array of permissions that are denied by the deny assignment. :vartype permissions: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] :ivar scope: The deny assignment scope. :vartype scope: str :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :vartype do_not_apply_to_child_scopes: bool :ivar principals: Array of principals to which the deny assignment applies. :vartype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :ivar exclude_principals: Array of principals to which the deny assignment does not apply. :vartype exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :vartype is_system_protected: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, "scope": {"key": "properties.scope", "type": "str"}, "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, "principals": {"key": "properties.principals", "type": "[Principal]"}, "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, description: Optional[str] = None, permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, scope: Optional[str] = None, do_not_apply_to_child_scopes: Optional[bool] = None, principals: Optional[List["_models.Principal"]] = None, exclude_principals: Optional[List["_models.Principal"]] = None, is_system_protected: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: The display name of the deny assignment. :paramtype deny_assignment_name: str :keyword description: The description of the deny assignment. :paramtype description: str :keyword permissions: An array of permissions that are denied by the deny assignment. :paramtype permissions: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] :keyword scope: The deny assignment scope. :paramtype scope: str :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :paramtype do_not_apply_to_child_scopes: bool :keyword principals: Array of principals to which the deny assignment applies. :paramtype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :keyword exclude_principals: Array of principals to which the deny assignment does not apply. :paramtype exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :paramtype is_system_protected: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.deny_assignment_name = deny_assignment_name self.description = description self.permissions = permissions self.scope = scope self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes self.principals = principals self.exclude_principals = exclude_principals self.is_system_protected = is_system_protected class DenyAssignmentFilter(_serialization.Model): """Deny Assignments filter. :ivar deny_assignment_name: Return deny assignment with specified name. :vartype deny_assignment_name: str :ivar principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :vartype principal_id: str :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :vartype gdpr_export_principal_id: str """ _attribute_map = { "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, "principal_id": {"key": "principalId", "type": "str"}, "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, principal_id: Optional[str] = None, gdpr_export_principal_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: Return deny assignment with specified name. :paramtype deny_assignment_name: str :keyword principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :paramtype principal_id: str :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :paramtype gdpr_export_principal_id: str """ super().__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id self.gdpr_export_principal_id = gdpr_export_principal_id class DenyAssignmentListResult(_serialization.Model): """Deny assignment list operation result. :ivar value: Deny assignment list. :vartype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[DenyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Deny assignment list. :paramtype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class DenyAssignmentPermission(_serialization.Model): """Deny assignment permissions. :ivar actions: Actions to which the deny assignment does not grant access. :vartype actions: list[str] :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. :vartype not_actions: list[str] :ivar data_actions: Data actions to which the deny assignment does not grant access. :vartype data_actions: list[str] :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Actions to which the deny assignment does not grant access. :paramtype actions: list[str] :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. :paramtype not_actions: list[str] :keyword data_actions: Data actions to which the deny assignment does not grant access. :paramtype data_actions: list[str] :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py
_models_py3.py
from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deny Assignment. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The deny assignment ID. :vartype id: str :ivar name: The deny assignment name. :vartype name: str :ivar type: The deny assignment type. :vartype type: str :ivar deny_assignment_name: The display name of the deny assignment. :vartype deny_assignment_name: str :ivar description: The description of the deny assignment. :vartype description: str :ivar permissions: An array of permissions that are denied by the deny assignment. :vartype permissions: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] :ivar scope: The deny assignment scope. :vartype scope: str :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :vartype do_not_apply_to_child_scopes: bool :ivar principals: Array of principals to which the deny assignment applies. :vartype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :ivar exclude_principals: Array of principals to which the deny assignment does not apply. :vartype exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :vartype is_system_protected: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, "scope": {"key": "properties.scope", "type": "str"}, "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, "principals": {"key": "properties.principals", "type": "[Principal]"}, "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, description: Optional[str] = None, permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, scope: Optional[str] = None, do_not_apply_to_child_scopes: Optional[bool] = None, principals: Optional[List["_models.Principal"]] = None, exclude_principals: Optional[List["_models.Principal"]] = None, is_system_protected: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: The display name of the deny assignment. :paramtype deny_assignment_name: str :keyword description: The description of the deny assignment. :paramtype description: str :keyword permissions: An array of permissions that are denied by the deny assignment. :paramtype permissions: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] :keyword scope: The deny assignment scope. :paramtype scope: str :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :paramtype do_not_apply_to_child_scopes: bool :keyword principals: Array of principals to which the deny assignment applies. :paramtype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :keyword exclude_principals: Array of principals to which the deny assignment does not apply. :paramtype exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :paramtype is_system_protected: bool """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.deny_assignment_name = deny_assignment_name self.description = description self.permissions = permissions self.scope = scope self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes self.principals = principals self.exclude_principals = exclude_principals self.is_system_protected = is_system_protected class DenyAssignmentFilter(_serialization.Model): """Deny Assignments filter. :ivar deny_assignment_name: Return deny assignment with specified name. :vartype deny_assignment_name: str :ivar principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :vartype principal_id: str :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :vartype gdpr_export_principal_id: str """ _attribute_map = { "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, "principal_id": {"key": "principalId", "type": "str"}, "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, principal_id: Optional[str] = None, gdpr_export_principal_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: Return deny assignment with specified name. :paramtype deny_assignment_name: str :keyword principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :paramtype principal_id: str :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :paramtype gdpr_export_principal_id: str """ super().__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id self.gdpr_export_principal_id = gdpr_export_principal_id class DenyAssignmentListResult(_serialization.Model): """Deny assignment list operation result. :ivar value: Deny assignment list. :vartype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[DenyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Deny assignment list. :paramtype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class DenyAssignmentPermission(_serialization.Model): """Deny assignment permissions. :ivar actions: Actions to which the deny assignment does not grant access. :vartype actions: list[str] :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. :vartype not_actions: list[str] :ivar data_actions: Data actions to which the deny assignment does not grant access. :vartype data_actions: list[str] :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Actions to which the deny assignment does not grant access. :paramtype actions: list[str] :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. :paramtype not_actions: list[str] :keyword data_actions: Data actions to which the deny assignment does not grant access. :paramtype data_actions: list[str] :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email
0.882611
0.374848
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py
_authorization_management_client.py
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client._send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() def __enter__(self) -> "AuthorizationManagementClient": self._client.__enter__() return self def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details)
0.813979
0.086285
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py
_configuration.py
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.833189
0.089058
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_by_id_request( schedule_definition_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py
_access_review_schedule_definitions_operations.py
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_by_id_request( schedule_definition_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.781372
0.074332